[BUG] Shell snapshot should capture PATH from bash's translated environment, not from the raw Windows environment
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
There is a PATH translation error occurring when claude code running on windows OS attempts to generate a shell snapshot. Claude code's own analysis follows:
How Claude Code generates the snapshot:
Claude Code reads the Windows process environment directly (not from bash) and writes each variable as a export KEY='value' line. Windows PATH is always semicolon-separated backslashes — Claude Code captures that literally into the snapshot. When bash later sources the snapshot, it overrides MSYS2's auto-translation (which would have converted everything to /c/Program Files/... format) with the raw Windows string.
Why editing the snapshot is ephemeral:
The snapshot is regenerated every time all snapshot files are deleted + Claude Code restarts. On regeneration, Claude Code reads Windows PATH again → same broken string → same problem.
Does the Windows OS PATH need to change?
No. The Windows PATH already has C:\Program Files\Git\cmd (which MSYS2 translates to /c/Program Files/Git/cmd correctly). The problem isn't missing entries — it's that the snapshot overrides MSYS2's good translation with the raw Windows string.
Is there a truly permanent fix?
Honestly, not without modifying Claude Code itself. The snapshot generation reads Windows environment variables, and Windows PATH is always semicolon/backslash by definition. Any edit we make to the snapshot will be lost on regeneration.
The most durable option available to us:
Put the PATH correction into settings.json in a way that takes effect even after the snapshot overrides it. However, the env block applies before bash starts, so the snapshot overrides it. There's no user-accessible hook that runs after the init file.
What Should Happen?
When Claude Code generates the shell snapshot on Windows, PATH should be captured from the bash process's translated environment — not from the raw Windows process environment. Git for Windows (bin\bash.exe) uses the MSYS2 runtime which automatically converts the Windows-style semicolon-separated PATH into a POSIX colon-separated path at process startup (e.g. C:\Program Files\Git\cmd → /c/Program Files/Git/cmd). By reading PATH before bash performs this translation and writing it as a literal string into the snapshot (export PATH='C:\Windows\...'), the snapshot overrides the correct POSIX PATH when it is sourced, making standard tools like git unfindable by name in subsequent bash commands.
The snapshot should either: (a) capture PATH after MSYS2 translation by running bash and querying its environment, (b) omit the PATH export entirely and let MSYS2 handle translation naturally, or (c) convert the Windows PATH to POSIX format using cygpath -u -p before writing it to the snapshot.
Error Messages/Logs
Steps to Reproduce
For the "Steps to reproduce" field:
1. Install Git for Windows (standard install toC:\Program Files\Git\) 2. Set the Windows user environment variableCLAUDE_CODE_GIT_BASH_PATHtoC:\Program Files\Git\bin\bash.exe3. Open Claude Code on Windows 11 4. Open any project and run a Bash tool command:echo "test" && git --version5. Observe thatechooutputs correctly butgitreportscommand not found6. Inspect the generated shell snapshot atC:\Users\<username>\.claude\shell-snapshots\snapshot-bash-*.sh7. Observe line 9:export PATH='C:\Program Files\...\;C:\WINDOWS\system32;...'— a Windows-style semicolon-separated PATH string 8. This export fires when the snapshot is sourced by bash, overriding MSYS2's automatic Windows→POSIX PATH translation (which runs at bash startup and would correctly exposegitas/c/Program Files/Git/cmd/git) 9. Workaround: manually edit the snapshot to replace line 9 withexport PATH="/c/Program Files/Git/bin:/c/Program Files/Git/usr/bin:${PATH}"— this restores functionality until the snapshot is regenerated
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude 1.1.4498 (24f768) 2026-02-26T19:47:09.000Z
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗