Skip to content

fix(tools): _find_bash on Windows prefers Git Bash over WSL shell (#47837) - #50191

Closed
lEWFkRAD wants to merge 2 commits into
NousResearch:mainfrom
lEWFkRAD:fix/windows-find-bash-wsl-precedence
Closed

fix(tools): _find_bash on Windows prefers Git Bash over WSL shell (#47837)#50191
lEWFkRAD wants to merge 2 commits into
NousResearch:mainfrom
lEWFkRAD:fix/windows-find-bash-wsl-precedence

Conversation

@lEWFkRAD

Copy link
Copy Markdown
Contributor

What does this PR do?

On native Windows with both WSL and Git for Windows installed, _find_bash() returned C:\Windows\System32\bash.exe (the WSL bridge process) because shutil.which("bash") ran before checking explicit Git paths. The WSL bridge does not support MSYS path translation (/c/Users/...), so every Windows filesystem path fails with "No such file or directory".

Fix: Reorder the resolution chain so explicit Git for Windows paths are checked first, then fall back to shutil.which("bash") with a guard that only accepts paths containing "Git" in the directory components.

Related Issue

Fixes #47837

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tools/environments/local.py — moved explicit Git for Windows path candidates before shutil.which("bash") call; added "git" in found.lower() guard on the fallback PATH lookup

How to Test

  1. Install Hermes Agent natively on Windows with WSL2 and Git for Windows
  2. Run hermes chat -q "run pwd" — should return a Windows path, not fail with "No such file or directory"
  3. Verify _find_bash() resolves to C:\Program Files\Git\bin\bash.exe not C:\Windows\System32\bash.exe

Checklist

  • Read Contributing Guide
  • Conventional Commits format
  • Searched for existing PRs — no duplicates found
  • Focused change — single file, no unrelated commits
  • Tests: no existing Windows test infra for this path
  • Tested on: Windows 11, Git Bash + WSL2
  • Cross-platform: change only affects Windows, guarded by _IS_WINDOWS

…usResearch#47837)

On native Windows with both WSL and Git for Windows installed,
shutil.which("bash") returned C:\Windows\System32\bash.exe
(the WSL bridge process) before checking explicit Git paths.
The WSL bridge does not support MSYS path translation so every
Windows filesystem path fails with "No such file or directory".

Approved approach per CONTRIBUTING.md cross-platform rules:
- Check explicit C:\Program Files\Git\bin\bash.exe FIRST
- Only fall back to shutil.which after that
- Add "git" in path.lower() guard to reject WSL bridge

Single-file change in tools/environments/local.py. No new deps.
@alt-glitch alt-glitch added type/bug Something isn't working tool/terminal Terminal execution and process management backend/local Local shell execution P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #47920 — both fix #47837 by reordering _find_bash() in tools/environments/local.py so explicit Git for Windows paths are checked before shutil.which("bash"), with a guard that the PATH fallback only accepts a "git" path (so the WSL System32 bash.exe bridge no longer shadows Git Bash). #47920 (opened 2026-06-17) is the earlier open PR with the same mechanism.

Resolve _find_bash conflict: keep upstream's portable-Git (%LOCALAPPDATA%\hermes\git)
lookup, but drop the unconditional shutil.which("bash") early return that would
re-shadow Git Bash with WSL System32 bash.exe (issue NousResearch#47837). Explicit Program Files
Git paths remain checked before the guarded PATH fallback.
@lEWFkRAD

lEWFkRAD commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing: upstream ad5f334 (fix(terminal): prefer Git for Windows bash over Linux bash on Windows) has since landed on main and implements this same fix - explicit Git-for-Windows locations are now checked before the PATH lookup, and Hermes additionally prefers its own portable Git install. #47837 is covered; this PR is obsoleted. (Same reason the duplicate #47920 was closed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution duplicate This issue or pull request already exists 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.

[Bug]: _find_bash() resolves to WSL bash before checking system Git-for-Windows paths on Native Windows

3 participants