ros2run python script without extension .py fails on windows + pixi
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #1345 by @dlanov — closed without merging
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- cli, operating-systems
Research direction
Start in ros2run/ros2run/api/init.py at run_executable, then reproduce ros2 run rqt_bag rqt_bag inside a Windows pixi shell. Trace how the executable path is passed to subprocess.Popen and verify that the command works for Python scripts without a .py extension while preserving normal executable behavior.
Written by the indexing model from the issue text.
Description
Generated by Generative AI
No response
Operating System:
Microsoft Windows [Version 10.0.26200.8875]
ROS version or commit hash:
rolling
RMW implementation (if applicable):
No response
RMW Configuration (if applicable):
No response
Client library (if applicable):
No response
'ros2 doctor --report' output
ros2 doctor --report
<COPY OUTPUT HERE>
Steps to reproduce issue
pixi shellros2 run rqt_bag rqt_bag
Expected behavior
working
Actual behavior
Traceback (most recent call last):
File "\?<path_to>\ros_ws.pixi\envs\default\Library\bin\ros2-script.py", line 33, in
sys.exit(load_entry_point('ros2cli==0.41.1', 'console_scripts', 'ros2')())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "<path_to>\ros_ws.pixi\envs\default\Lib\site-packages\ros2cli\cli.py", line 91, in main
rc = extension.main(parser=parser, args=args)
File "<path_to>\ros_ws.pixi\envs\default\Lib\site-packages\ros2run\command\run.py", line 110, in main
return run_executable(path=path, argv=args.argv, prefix=prefix)
File "<path_to>\ros_ws.pixi\envs\default\Lib\site-packages\ros2run\api_init_.py", line 64, in run_executable
process = subprocess.Popen(cmd)
File "<path_to>\ros_ws.pixi\envs\default\Lib\subprocess.py", line 1039, in init
self._execute_child(args, executable, preexec_fn, close_fds,
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass_fds, cwd, env,
^^^^^^^^^^^^^^^^^^^
...<5 lines>...
gid, gids, uid, umask,
^^^^^^^^^^^^^^^^^^^^^^
start_new_session, process_group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<path_to>\ros_ws.pixi\envs\default\Lib\subprocess.py", line 1553, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
# no special security
^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
cwd,
^^^^
startupinfo)
^^^^^^^^^^^^
OSError: [WinError 193] %1 は有効な Win32 アプリケーションではありません。
Additional information
Many executables of ros2 , such as rqt_bag, are python codes without ".py" extension, but Windows doesn't recognize shebang without py.exe, and pixi doesn't use py.exe.
I'm not sure whether there are any mechanisms of generating execution wrappers for them in case of Windows, or they weren't work for some reasons.
My suggestion is to add checking a shebang of an executable on running. I'm afraid I've not covered all the possible shebangs for Python.
https://github.com/ros2/ros2cli/blob/4eaefee77c3a66c2f724f56096539f009bb576a8/ros2run/ros2run/api/__init__.py#L58
def _check_shebang_python(path):
import re
shebang_python_cmds=["/usr/bin/env python3", "/usr/bin/python3", "/usr/bin/env python", "/usr/bin/python"]
with open(path,"r") as fp:
if fp.read(2) == '#!': #shebang
shebang_cmd=re.sub("[\r\n]+$","",fp.readline())
if shebang_cmd in shebang_python_cmds:
return True
return False
def run_executable(*, path, argv, prefix=None):
cmd = [path] + argv
if os.name == 'nt' and ( path.endswith('.py') or _check_shebang_python(path) ):
cmd.insert(0, sys.executable)
- Dominant language
- Python
- Stars
- 274
- Forks
- 246
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 12
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/ros2cli
-
ros2 CLI prints BrokenPipeError traceback when output is piped to a command that exits early (e.g. head)May be free again @akshat-lakhera claimed this 38 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
ros2/ros2cli#1342 · 2 comments ·
Maintainers usually reply within 1 day
-
Add --timeout alias to ros2 topic pub and ros2 param listPossibly taken @1cbyc claimed this 63 days ago. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
ros2/ros2cli#1305 · 2 comments ·
Maintainers usually reply within 1 day
-
ros2doctor: UserWarning: Fail to call PackageReport/RosdistroReport class functions.Possibly taken @sujanchalla0510 claimed this 13 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 20/100
Maintainers usually reply within 1 day
-
Add --all alias to commands that include hidden nodes, topics, or servicesPossibly taken @Rajat-Arora claimed this 62 days ago. Opengood first issue
Difficulty 3/5 1-2 days Newbie friendliness 78/100
ros2/ros2cli#1302 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
extend `ros2 topic info -v` with buffer-backend fieldPossibly taken @fujitatomoya claimed this 161 days ago. Openenhancement
ros2/ros2cli#1245 · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
hive size:simple
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
backend enhancement priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
geolens-io/geolens#4161 ·
Maintainers usually reply within 1 day