`ctx.run` inside `ctx.cd` fails when path contains spaces on Windows
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- cli, operating-systems
Research direction
Start at invoke/context.py around ctx.cwd, then run the provided task reproduction on Windows with a temporary directory whose path contains spaces. Trace how the cwd is turned into the shell command and verify that ctx.run("whoami") succeeds inside ctx.cd(d) without the path error.
Written by the indexing model from the issue text.
Description
example
@task
def repro(ctx):
import tempfile
d = tempfile.mkdtemp(prefix="with space")
with ctx.cd(d):
ctx.run("whoami")
output
The system cannot find the path specified.
debug output
The system cannot find the path specified.
invoke.program.run: Received a possibly-skippable exception: <UnexpectedExit: cmd='cd C:\\Users\\BRANDE~1.CLA\\AppData\\Local\\Temp\\with\\ spacekk8c0niv && whoami' exited=1>
it looks like ctx.cwd improperly escapes the whitespace for Windows by adding a backslash. If using the cd command this way the path should be enclosed in double quotes. Why do you use the cd command instead of the cwd parameter to subprocess.Popen?
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 412
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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 pyinvoke/invoke
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·