fix(agent,cli): skip WSL/system bash.exe in Windows bash discovery (#116818)

_windows_bash_candidates in tools/environments/local.py appended
shutil.which("bash") to the candidate list without filtering — when Git Bash
is installed but PATH resolves `bash` to WSL's stub (C:\Windows\System32\bash.exe)
or WindowsApps bash.exe, that stub enters the candidate list.

Fix: skip paths whose normalized form contains `system32` or `windowsapps`,
logging at debug level. Git Bash (already searched explicitly in the roots list)
remains the first usable candidate.

Fixes #116818
This commit is contained in:
chugiacan
2026-09-20 14:50:53 +07:00
committed by Teknium
parent 1a24b851e5
commit 0abc3b044b

View File

@@ -462,7 +462,13 @@ def _windows_bash_candidates(custom: "str | None") -> list[str]:
candidates = list(dict.fromkeys(c for c in raw if c and os.path.isfile(c)))
found = shutil.which("bash")
if found and found not in candidates:
candidates.append(found)
# Skip WSL/system bash.exe (C:\Windows\System32\bash.exe or
# WindowsApps bash.exe) — it is a stub launcher, not a usable shell.
norm = os.path.normpath(found).lower()
if "system32" in norm or "windowsapps" in norm:
logger.debug("Skipping WSL/system bash.exe at %s", found)
else:
candidates.append(found)
return candidates