fix(windows): terminal drain and cwd path conversion#19258
Closed
alanxchen85 wants to merge 1 commit into
Closed
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
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.
Summary
_drain()inbase.py:select.select()only works on sockets on Windows, not pipe fds. Added a Windows branch using blockingos.read()in the daemon thread instead. EOF arrives promptly when bash exits._run_bash()inlocal.py:self.cwdfrompwdoutput uses Git Bash paths (/c/Users/...), butsubprocess.Popen(cwd=...)needs native Windows paths (C:\Users\...). Added conversion before Popen.Without these, all
terminal()calls on Windows return empty output with exit 126, and cwd tracking breaks completely.Test plan
terminal("echo hello")returns correct output (was empty before)__HERMES_CWD__marker correctly parsed after fixos.name == "nt")Fixes #14638
🤖 Generated with Claude Code