[BUG] Shell snapshots export empty PATH on Windows (Git Bash), breaking command execution
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?
Description
On Windows with Git Bash, Claude Code generates shell snapshots that explicitly set PATH='', causing all subsequent Bash commands to fail with exit code 127 (command not found).
## Environment
- OS: Windows 10/11
- Shell: Git Bash (MINGW64)
- Claude Code Version: Latest
- Terminal: Tabby / PowerShell (launching Claude Code)
## Steps to Reproduce
- Launch Claude Code on Windows
- Execute any Bash command (e.g.,
which node,ls, etc.) - Command fails with exit code 127
## Root Cause
The generated snapshot files in ~/.claude/shell-snapshots/ contain:
```bash
# Line 85
export PATH=''
This explicitly clears the PATH variable. However, ORIGINAL_PATH environment variable correctly preserves the full system PATH.
Evidence
$ echo $PATH
# (empty)
$ echo $ORIGINAL_PATH
/mingw64/bin:/usr/bin:/c/Users/username/bin:...
Snapshot file content (last line):
export PATH=''
Expected Behavior
The snapshot should either:
- Not override PATH at all
- Use export PATH="$ORIGINAL_PATH" if PATH needs to be set
- Preserve the actual PATH value from the shell environment
Workaround
Manually edit snapshot files to replace export PATH='' with export PATH="$ORIGINAL_PATH", or prefix every command with export PATH="$ORIGINAL_PATH" &&.
Additional Context
- Deleting snapshots and restarting Claude Code regenerates the same broken snapshots
- The issue persists across sessions
- Only affects Bash tool; other tools work normally
What Should Happen?
On Windows with Git Bash, Claude Code generates shell snapshots that explicitly set PATH='', causing all subsequent Bash commands to fail with exit code 127 (command not found).
Error Messages/Logs
Steps to Reproduce
- Launch Claude Code on Windows
- Execute any Bash command (e.g.,
which node,ls, etc.) - Command fails with exit code 127
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.75
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Additional Context
- Deleting snapshots and restarting Claude Code regenerates the same broken snapshots
- The issue persists across sessions
- Only affects Bash tool; other tools work normally
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗