Your Script Called bash. Windows Gave It WSL, Not Git Bash.
Ronin Supply Co
0:00 / 0:00
Your Script Called bash. Windows Gave It WSL, Not Git Bash.
10 просмотров · 7 дн. назад
Ronin Supply Co
4 подписчика
10 просмотров · 7 дн. назад
Your build script shells out to bash. You test the command by hand and it is correct. From inside the script the same word runs a different shell, against a different filesystem, under a different kernel. Nothing errors. The output is just wrong.
where.exe bash on a normal dev box returns three entries - Git for Windows at usr/bin/bash.exe, C:\Windows\System32\bash.exe which is the WSL launcher, and a WindowsApps stub. Git is first, so PATH order is not the problem. That is exactly why it looks fine when you check it.
Two resolvers disagree. Your shell asks PATH, and PATH says Git. A script does not go through your shell - it calls CreateProcess with a bare name, and CreateProcess searches the Windows system directory before it touches PATH. System32 holds the WSL launcher, so the script gets WSL regardless of PATH.
Both answers out of one process:
python -c "import shutil,subprocess; print('lookup :', shutil.which('bash')); print('spawned:', subprocess.run(['bash','-c','uname -s'],capture_output=True,text=True).stdout.strip())"
lookup : C:\Program Files\Git\usr\bin\bash.EXE
spawned: Linux
The fix is to never spawn a bare interpreter name from a script. Resolve it to an absolute path first, derived from something you already trust on PATH:
import shutil, subprocess
from pathlib import Path
git = shutil.which("git")
bash = next(p / "usr" / "bin" / "bash.exe"
for p in Path(git).parents
if (p / "usr" / "bin" / "bash.exe").exists())
subprocess.run([str(bash), "-c", "uname -s"])
That survives a machine where Git sits on another drive, and it cannot be hijacked by whatever Windows ships in System32 next.
This one is expensive with coding agents. The agent runs a command, gets plausible output from the wrong shell and the wrong filesystem, and builds its next three steps on it. No error appears anywhere in the transcript.
Verified on Windows 11 26300, Git for Windows (MINGW64), WSL bash at C:\Windows\System32\bash.exe, Python 3.11.
Free starter kit - the CLAUDE.md rules that pin interpreters by absolute path:
https://guzmancer0.gumroad.com/l/cco-...
CHAPTERS
00:00 Typed it works, spawned it does not
00:16 where.exe bash returns three answers
00:40 MINGW64 by hand, Linux from a script
01:05 CreateProcess searches System32 before PATH
01:36 The fix - resolve Git Bash from git
01:59 Why this wrecks coding agents
This channel covers Windows-native agentic coding - the failure modes the macOS tutorials never reach. Subscribe if you build on Windows and are tired of being told to just use WSL.
#windows #python #wsl