From 0abc3b044b13e104e9b7b3dc835ecb1515f84aa5 Mon Sep 17 00:00:00 2001 From: chugiacan Date: Sun, 20 Sep 2026 14:50:53 +0700 Subject: [PATCH] fix(agent,cli): skip WSL/system bash.exe in Windows bash discovery (#116818) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _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 --- tools/environments/local.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/environments/local.py b/tools/environments/local.py index 84588df3a5..894af95a1f 100644 --- a/tools/environments/local.py +++ b/tools/environments/local.py @@ -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