-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Description
If I define a simple task, with the newly required context:
@task
def test(ctx):
ctx.run('dir')
This task should display a directory listing. Instead (on Windows 10, Python 3.5.2, Invoke 0.13), it breaks and displays the following traceback:
Traceback (most recent call last):
File "c:\program files\python 3.5\lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\python 3.5\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python 3.5\Scripts\invoke.exe\__main__.py", line 9, in <module>
File "c:\program files\python 3.5\lib\site-packages\invoke\program.py", line 270, in run
self.execute()
File "c:\program files\python 3.5\lib\site-packages\invoke\program.py", line 381, in execute
executor.execute(*self.tasks)
File "c:\program files\python 3.5\lib\site-packages\invoke\executor.py", line 113, in execute
result = call.task(*args, **call.kwargs)
File "c:\program files\python 3.5\lib\site-packages\invoke\tasks.py", line 111, in __call__
result = self.body(*args, **kwargs)
File "S:\Documents\GitHub\blog.minchin.ca-pelican\tasks.py", line 106, in test
ctx.run('dir')
File "c:\program files\python 3.5\lib\site-packages\invoke\context.py", line 53, in run
return runner_class(context=self).run(command, **kwargs)
File "c:\program files\python 3.5\lib\site-packages\invoke\runners.py", line 259, in run
self.start(command, shell, env)
File "c:\program files\python 3.5\lib\site-packages\invoke\runners.py", line 966, in start
stdin=PIPE,
File "c:\program files\python 3.5\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "c:\program files\python 3.5\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 3] The system cannot find the path specified
I believe this is because the default shell (/bin/bash) in unavailable, at least by that name, on the default Windows CMD. If you try to run /bin/bash on Windows CMD, it will display a similar error message ("The system cannot find the path specified").
Setting the shell on the run command with the full path of CMD seems to fix it. I.e. the following works as expected:
@task
def test(ctx):
ctx.run('dir', shell="C:\Windows\system32\cmd.EXE")
Setting the shell to just the name of the exacutable ("cmd" or "cmd.exe") don't work.
- So, how to I change the default shell in my default context? (I couldn't find that searching the docs)
- Can Invoke have a Windows native default shell when running on Windows? (CMD or Powershell, I'm not particularly picky; I just want it to work out of the box)
- If the default shell is going to remain unchanged, can the documentation be updated to note that the defaults break on Windows, and how to work around it?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels