Windows: hooks with "shell": "bash" fail with "Git Bash was not found" when Git is installed under the session cwd
What happens
With a per-user Git for Windows install (%LOCALAPPDATA%\Programs\Git), a hook declaring "shell": "bash" fails at session start:
SessionStart:startup hook error Failed to run: Hook "..." requires bash but Git Bash was not found. Install Git for Windows (https://git-scm.com/downloads/win), or add "shell": "powershell" to this hook's config.
Git Bash is installed and git is on PATH; bash.exe is present at %LOCALAPPDATA%\Programs\Git\bin\bash.exe.
Why
Bash resolution tries CLAUDE_CODE_GIT_BASH_PATH, then the two C:\Program Files\Git... paths, then derives from where git as <git.exe>\..\..\bin\bash.exe. The where results are filtered: a candidate located inside process.cwd() is skipped (reasonable protection against a cwd-local binary being picked up). But a per-user Git lives under the user profile, so when the session cwd is C:\Users\<me> — or any ancestor of the install — the only correct candidate is discarded and resolution returns null.
Repro (Windows 11, Claude Code 2.1.224, per-user Git, no CLAUDE_CODE_GIT_BASH_PATH set)
- Configure any hook with
"shell": "bash". - Start Claude Code with cwd
C:\Users\<me>→ hook fails as above. - Start it in
C:\dev\<anything>→ the derivation should succeed, since the Git install is no longer inside cwd.
Observed vs. derived — step 2 is observed: the failure above occurred in a session whose cwd was C:\Users\<me>, with no CLAUDE_CODE_GIT_BASH_PATH set and bash.exe present on disk. The resolver order and the cwd filter are read from the 2.1.224 binary; step 3 is the only branch that could have succeeded on this machine, and the cwd filter is the only thing that would stop it. I have not run a clean control for step 3 — applying the workaround came first, so later sessions resolve via step 1 regardless of cwd. If the cwd dependence holds, it also explains why this reads as intermittent across sessions.
Expected
A per-user Git install should resolve regardless of cwd — e.g. also probe %LOCALAPPDATA%\Programs\Git\bin\bash.exe directly, or exempt the derived git-relative path from the cwd filter. Failing that, the error text should not tell the user to install Git for Windows when a Git install was found and rejected.
Workaround
"env": { "CLAUDE_CODE_GIT_BASH_PATH": "C:\\Users\\<me>\\AppData\\Local\\Programs\\Git\\bin\\bash.exe" } in ~/.claude/settings.json.
Environment: Claude Code 2.1.224 (native install), Windows 11 Enterprise 26200, PowerShell 7. Report written with Claude Opus 5 in Claude Code.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗