Skip to content

fix(terminal): prefer Git for Windows bash over non-MSYS bash on Windows - #46586

Closed
Icather wants to merge 1 commit into
NousResearch:mainfrom
Icather:fix/windows-bash-find-order
Closed

fix(terminal): prefer Git for Windows bash over non-MSYS bash on Windows#46586
Icather wants to merge 1 commit into
NousResearch:mainfrom
Icather:fix/windows-bash-find-order

Conversation

@Icather

@Icather Icather commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Problem

On Windows machines with both a Linux environment and Git for Windows installed, _find_bash() calls shutil.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 like C:\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.exe etc.) before falling back to shutil.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 the shutil.which("bash") block from after portable Git to after system Git path checks.

Related

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)
Copilot AI review requested due to automatic review settings June 15, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.exe before falling back to shutil.which("bash").

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/environments/local.py
@alt-glitch alt-glitch added type/bug Something isn't working comp/tools Tool registry, model_tools, toolsets tool/terminal Terminal execution and process management backend/local Local shell execution P2 Medium — degraded but workaround exists labels Jun 15, 2026
@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #56384 — your _find_bash() reorder (Git for Windows before the WSL shim on PATH) was cherry-picked onto current main with your authorship preserved (commit ad5f334). This became Layer 1 of the fix: forcing one canonical MSYS bash so the /c/ path dialect is always correct. Thanks!
#56384

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

Labels

backend/local Local shell execution comp/tools Tool registry, model_tools, toolsets 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.

4 participants