Skip to content

fix(windows): terminal drain and cwd path conversion#19258

Closed
alanxchen85 wants to merge 1 commit into
NousResearch:mainfrom
alanxchen85:fix/windows-terminal-drain-and-cwd
Closed

fix(windows): terminal drain and cwd path conversion#19258
alanxchen85 wants to merge 1 commit into
NousResearch:mainfrom
alanxchen85:fix/windows-terminal-drain-and-cwd

Conversation

@alanxchen85

Copy link
Copy Markdown
Contributor

Summary

  • _drain() in base.py: select.select() only works on sockets on Windows, not pipe fds. Added a Windows branch using blocking os.read() in the daemon thread instead. EOF arrives promptly when bash exits.
  • _run_bash() in local.py: self.cwd from pwd output uses Git Bash paths (/c/Users/...), but subprocess.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

  • Tested on Windows 11 + Git for Windows + Python 3.13
  • terminal("echo hello") returns correct output (was empty before)
  • __HERMES_CWD__ marker correctly parsed after fix
  • No regression on Unix (Windows branch is gated on os.name == "nt")

Fixes #14638

🤖 Generated with Claude Code

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
@alt-glitch alt-glitch added type/bug Something isn't working backend/local Local shell execution tool/terminal Terminal execution and process management P2 Medium — degraded but workaround exists labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Terminal exits 126 with empty output on every command (Git Bash backend)

2 participants