Permission denied error after every Bash command when Windows username contains a space
Bug Description
After every Bash tool command execution, the following error appears:
/usr/bin/bash: line 1: /c/Users/Zane: Permission denied
The error is caused by Claude Code's shell state management spawning a child bash process with an unquoted path that contains a space (from the Windows username).
Environment
- OS: Windows 11 Home 10.0.26200
- Shell: Git Bash (MINGW64)
- Claude Code version: 2.1.63 (installed globally via npm)
- Windows username:
Zane Hill(contains a space) - Home directory:
C:\Users\Zane Hill→/c/Users/Zane Hillin Git Bash
Steps to Reproduce
- Have a Windows user account with a space in the username (e.g., "Zane Hill")
- Install Claude Code globally via npm
- Run any Bash tool command (even
echo "test") - Observe the error appended after every command's output
Expected Behavior
Commands should execute without the spurious "Permission denied" error.
Actual Behavior
Every Bash tool invocation produces the error:
/usr/bin/bash: line 1: /c/Users/Zane: Permission denied
The error comes from a child bash process (note the /usr/bin/bash: prefix, not just bash:), and line 1 indicates it's a one-liner command string. Bash is splitting the unquoted path /c/Users/Zane Hill at the space and trying to execute /c/Users/Zane as a command, which fails because it's a directory.
Investigation Details
The following were ruled out as causes:
- No
.bashrc,.bash_profile, or.profileexist in the home directory - Error persists even with
bash --norc --noprofile PROMPT_COMMANDis emptyPS0is empty- PowerShell execution policy is
Unrestricted(not a PowerShell issue) - No Windows
AutoRunregistry keys set - All Claude Code plugin hooks were reviewed and are properly quoted
This confirms the issue is in Claude Code's internal shell management code — likely where it constructs a bash command to capture shell state (working directory, environment) after each Bash tool execution, and the path is not properly quoted.
Workaround
The error is cosmetic — commands still execute correctly. However, the error noise is confusing and makes it appear that commands are failing (exit code 1).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗