fix(terminal): prefer Git for Windows bash over non-MSYS bash on Windows - #46586
Closed
Icather wants to merge 1 commit into
Closed
fix(terminal): prefer Git for Windows bash over non-MSYS bash on Windows#46586Icather wants to merge 1 commit into
Icather wants to merge 1 commit into
Conversation
On Windows machines with both Linux and Git for Windows installed,
_find_bash() called shutil.which('bash') before checking known
Git-for-Windows install paths. shutil.which() may return a
non-MSYS bash which does not understand Windows-style paths.
This caused all terminal commands to fail with exit code 126
because the cwd prefix (a Windows path) was rejected.
Reorder the search: check Git for Windows install locations
(ProgramFiles/Git/bin/bash.exe etc.) before falling back to
PATH lookup. This matches the intent of the surrounding code
(portable Git preferred, system Git preferred, then PATH as
last resort).
Related: NousResearch#23846 (same file, same class of Windows path issues)
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts Git Bash discovery to prefer Git-for-Windows bash over PATH resolution, reducing cases where WSL-related bash is selected on Windows.
Changes:
- Check common Git-for-Windows install locations for
bash.exebefore falling back toshutil.which("bash").
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Merged via PR #56384 — your |
This was referenced Aug 3, 2026
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.
Problem
On Windows machines with both a Linux environment and Git for Windows installed,
_find_bash()callsshutil.which("bash")before checking known Git-for-Windows install paths.shutil.which()may return a non-MSYS bash (e.g., Linux subsystem bash at/usr/bin/bash) which does not understand Windows-style paths likeC:\Users\Asus.Result: every terminal command fails with exit code 126 because the cwd prefix injected by the tool wrapper is rejected by the non-MSYS bash. The command after
&&never executes.Fix
Reorder the search in
_find_bash(): check explicit Git-for-Windows install locations (ProgramFiles/Git/bin/bash.exeetc.) before falling back toshutil.which("bash").This matches the intent of the surrounding code — portable Git is already preferred, system Git should also be preferred, and PATH lookup is the last resort.
Change
tools/environments/local.py— moved theshutil.which("bash")block from after portable Git to after system Git path checks.Related