[BUG] Windows - Bash tool fails with "Permission denied" on Windows when username contains a space
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 / MSYS2 / PowerShell), every Bash tool invocation produces a spurious error when the Windows user profile path contains a space:
/usr/bin/bash: line 1: /c/Users/John: Permission denied
The shell interprets the first word of the unquoted $HOME path (/c/Users/John) as a command to execute, because HOME is set to /c/Users/John Doe and is expanded without quotes somewhere in Claude Code's internal shell initialization.
Environment
- OS: Windows 11 Pro (25H2) x86\_64, build 10.0.26200
- Shell: Git Bash (MSYS2) via
/usr/bin/bash, PowerShell - Terminal: Warp / Windows Terminal
- Claude Code version: 2.1.45/47/48/50 (tested across multiple versions)
- HOME:
/c/Users/John Doe
What Should Happen?
Expected behavior
$HOMEshould be quoted wherever it is used in Claude Code's bash initialization (e.g."$HOME")- Commands on accounts with spaces in the username should execute without spurious errors
- Exit codes should reflect actual command success/failure
Error Messages/Logs
Error: Exit code 1
/usr/bin/bash: line 1: /c/Users/John: Permission denied
/usr/bin/bash: line 1: /c/Users/John: Permission denied
Steps to Reproduce
Steps to reproduce
- Have a Windows user account with a space in the name (e.g.
John Doe) - Run any Bash command in Claude Code, even a trivial one:
``bash``
echo "hello"
- Observe the error appended to every command output:
````
/usr/bin/bash: line 1: /c/Users/John: Permission denied
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.44
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
Key observations
- The error appears on every single Bash invocation, including
bash --norc --noprofile -c "echo clean", confirming the issue is in Claude Code's own shell wrapper, not in user profile files (.bashrc,.bash_profile, etc.). - Commands still execute and produce correct output — the error is additional.
- The error is always
line 1, suggesting it occurs during Claude Code's shell environment initialization before the user's command runs. - All exit codes are reported as
1regardless of actual command success, which can break scripts that check exit codes.
Expected behavior
$HOMEshould be quoted wherever it is used in Claude Code's bash initialization (e.g."$HOME")- Commands on accounts with spaces in the username should execute without spurious errors
- Exit codes should reflect actual command success/failure
Workarounds attempted
| Workaround | Result |
| ---------------------------------------------- | -------------------------------------------------------------------------------------- |
| bash --norc --noprofile | Error persists — not a profile issue |
| Set CLAUDE_CONFIG_DIR to space-free junction | Fixes config paths but not the shell init error |
| Set HOME to 8.3 short name in .bashrc | HOME is correct after profile loads, but error still fires before profile is sourced |
Root cause hypothesis
Claude Code's Bash tool likely constructs the shell environment or evaluates $HOME without double-quoting it before the user's command is executed. On Windows/MSYS2 where HOME can contain spaces, the unquoted expansion causes word splitting. The first token (/c/Users/John) is treated as a command, producing Permission denied.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗