fix(windows): terminal drain + cwd path conversion (salvage #19258)#21259
Merged
Conversation
Two fixes for the local terminal backend on Windows (Git Bash): 1. `_drain()` in base.py: `select.select()` only works on sockets on Windows, not pipe file descriptors. On Windows, use blocking `os.read()` in the daemon thread instead. EOF arrives promptly when bash exits, so this is safe. 2. `_run_bash()` in local.py: When `self.cwd` is updated from `pwd` output, it contains Git Bash-style paths (`/c/Users/...`). `subprocess.Popen(cwd=...)` needs a native Windows path (`C:\Users\...`). Added a conversion before Popen. Without these fixes, all terminal() calls on Windows return empty output (exit code 126), and cwd tracking breaks. Tested on Windows 11 with Git for Windows + Python 3.13. Fixes #14638
Contributor
🔎 Lint report:
|
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.
Closes #19258 via salvage. Fixes #14638.
Summary
Two Windows-only local terminal bugs:
_drain()inbase.pyusesselect.select()which only works on sockets on Windows, not pipe fds. Switch to blockingos.read()in the daemon thread on nt._run_bash()inlocal.pygets Git Bash paths (/c/Users/...) frompwdbutsubprocess.Popen(cwd=...)needs native Windows paths (C:\Users\...). Convert before Popen.Without these,
terminal()on Windows returns empty output with exit code 126 and cwd tracking breaks.Improvements during salvage
_resolve_safe_cwdrecovery (forrm -rfof the current directory, issue [Bug]: persistent_shell carries cwd into deleted directory; subsequent Popen calls fail with ENOENT until gateway restart #17558), then applied the Windows path conversion on top. Both guards now run in sequence.Validation
scripts/run_tests.sh tests/tools/ -k 'environment or local'→ 295 passed + 4 pre-existing failures unrelated to this change (daytona/vercel/browser tests already failing on main).Original author: @alanxchen85.