Skip to content

Windows: Multiple arguments unsupported #113

Open
@robertschweizer

Description

@robertschweizer

Single-argument commands work, e.g.

from subprocess_tee import run
run(["git"])

With multiple arguments, an error is raised:

$ python -c "from subprocess_tee import run; run(['git status'])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\Python39\lib\site-packages\subprocess_tee\__init__.py", line 142, in run
    result = asyncio.run(_stream_subprocess(cmd, **kwargs))
  File "C:\Program Files\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "C:\Program Files\Python39\lib\site-packages\subprocess_tee\__init__.py", line 67, in _stream_subprocess
    process = await asyncio.create_subprocess_shell(
  File "C:\Program Files\Python39\lib\asyncio\subprocess.py", line 216, in create_subprocess_shell
    transport, protocol = await loop.subprocess_shell(
  File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 1643, in subprocess_shell
    transport = await self._make_subprocess_transport(
  File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 3[94], in _make_subprocess_transport
    transp = _WindowsSubprocessTransport(self, protocol, args, shell,
  File "C:\Program Files\Python39\lib\asyncio\base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "C:\Program Files\Python39\lib\asyncio\windows_events.py", line 890, in _start
    self._proc = windows_utils.Popen(
  File "C:\Program Files\Python39\lib\asyncio\windows_utils.py", line 153, in __init__
    super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd,
  File "C:\Program Files\Python39\lib\subprocess.py", line [95]1, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 3] The system cannot find the path specified

The reason is probably that platform_settings["executable"] is set on Windows: https://github.com/pycontribs/subprocess-tee/blob/v0.4.1/src/subprocess_tee/__init__.py#L57-L58

Workaround

Pass executable=None:

from subprocess_tee import run
run(["git", "status"], executable=None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions