fix: prevent _update_cwd from overwriting self.cwd with POSIX paths on Windows#17342
Closed
hypen-o wants to merge 1 commit into
Closed
fix: prevent _update_cwd from overwriting self.cwd with POSIX paths on Windows#17342hypen-o wants to merge 1 commit into
hypen-o wants to merge 1 commit into
Conversation
…n Windows On Windows with Git Bash, _update_cwd() reads the output of 'pwd -P' which returns POSIX-style paths (e.g. /c/Users/msn). These paths are invalid for subprocess.Popen(cwd=...), causing WinError 267. This fix adds a Windows guard: on Windows, _update_cwd() still strips the CWD marker from stdout (for clean output) but preserves the original self.cwd (which was set by the TERMINAL_CWD config or the initial Windows path detection).
Collaborator
Collaborator
|
Likely duplicate of #16628 |
3 tasks
Contributor
|
Automated hermes-sweeper review: this Windows Git Bash cwd issue is already fixed on current main. Evidence:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Prevent
_update_cwd()from overwritingself.cwdwith Git Bash POSIX paths on Windows.Why
On Windows,
_update_cwd()reads a temp file written by Git Bash'spwd -Pcommand.Git Bash always returns POSIX-style paths (
/d/users/hermes), which are not valid forsubprocess.Popen(cwd=...):Root cause chain
LocalEnvironment.init_session()setsself.cwdcorrectly (Windows path from config or detection)_update_cwd()reads Git Bash'spwd -Poutput → POSIX path (/d/...)self.cwd→ nextsubprocess.Popen(cwd=...)failsFix
On Windows,
_update_cwd()still calls_extract_cwd_from_output()to strip the CWD marker from stdout (keeping output clean), but restores the originalself.cwdinstead of using the POSIX path from the temp file.The
_IS_WINDOWSconstant already exists atlocal.py:12for other platform guards.Verification
D:\...\Git\bin\bash.exe)TERMINAL_CWDset in.envterminal()calls succeed (previously the second call failed)Alternatives considered
_update_cwd()_update_cwd()entirely on Windowsself.cwdis already valid