Permission denied error after every Bash command when Windows username contains a space

Resolved 💬 3 comments Opened Feb 28, 2026 by zhill-quandry Closed Mar 3, 2026

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 Hill in Git Bash

Steps to Reproduce

  1. Have a Windows user account with a space in the username (e.g., "Zane Hill")
  2. Install Claude Code globally via npm
  3. Run any Bash tool command (even echo "test")
  4. 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 .profile exist in the home directory
  • Error persists even with bash --norc --noprofile
  • PROMPT_COMMAND is empty
  • PS0 is empty
  • PowerShell execution policy is Unrestricted (not a PowerShell issue)
  • No Windows AutoRun registry 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).

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗