"Permission denied" error on Windows when username contains spaces (unquoted temp file path)
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 (Git Bash / MINGW64), every Bash tool invocation produces the error:
/usr/bin/bash: line 1: /c/Users/User: Permission denied
This happens because Claude Code appends an unquoted path to the bash -c command for tracking the current working directory:
```bash
pwd -P >| /c/Users/User Name/AppData/Local/Temp/claude-XXXX-cwd
Since the username (User Name) contains a space and the path is not quoted, bash word-splits it:
- pwd -P >| /c/Users/User → tries to write to a directory → Permission denied
- Name/AppData/Local/Temp/claude-XXXX-cwd → interpreted as a separate command
Expected behavior
The temp file path should be quoted:
pwd -P >| '/c/Users/User Name/AppData/Local/Temp/claude-XXXX-cwd'
Note: the shell-snapshot source path IS correctly quoted with single quotes — only the cwd redirect path is missing quotes.
Environment
- OS: Windows 11 Pro
- Shell: Git Bash (MINGW64)
- Username: Contains a space
- Claude Code model: claude-opus-4-6
Evidence
From ps -ef output showing the constructed command:
/usr/bin/bash -c source '/c/Users/User Name/.claude/shell-snapshots/snapshot-bash-XXXX.sh' && shopt -u extglob 2>/dev/null || true && eval '...' && pwd -P >|
/c/Users/User Name/AppData/Local/Temp/claude-XXXX-cwd
The source path is quoted ✅
The >| redirect path is NOT quoted ❌
What Should Happen?
The temp file path in the pwd -P >| redirect should be quoted to handle paths with spaces. For example:
pwd -P >| '/c/Users/User Name/AppData/Local/Temp/claude-XXXX-cwd'
This would match the existing behavior of the source command in the same line, which already quotes the path correctly.
Error Messages/Logs
/usr/bin/bash: line 1: /c/Users/User: Permission denied
Steps to Reproduce
- Use Claude Code on Windows (Git Bash / MINGW64) with a username that contains a space (e.g., "User Name")
- Run any Bash tool command (e.g.,
echo "hello") - The error
/usr/bin/bash: line 1: /c/Users/User: Permission deniedappears after every command
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.69
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗