Bash tool error on Windows when username contains spaces

Resolved 💬 4 comments Opened Feb 14, 2026 by jz223 Closed Apr 6, 2026

Description

Every Bash tool invocation produces a Permission denied error on line 1 when the Windows username contains spaces:

/usr/bin/bash: line 1: /c/Users/FirstName: Permission denied

Commands still execute correctly after the error, but the error message appears on every single invocation.

Environment

  • OS: Windows 11 Pro (10.0.22621)
  • Shell: Git Bash (MSYS2)
  • Claude Code version: latest
  • Windows username: Contains a space (e.g. First Last)

Root Cause

BASH_EXECUTION_STRING contains:

source '/c/Users/First Last/.claude/shell-snapshots/snapshot-bash-XXXX.sh' && shopt -u extglob 2>/dev/null || true && eval "<command>"

The path to the shell snapshot file is properly quoted in the source command, but something at bash initialization (line 1) appears to word-split the path before the source command runs. This causes /c/Users/First to be interpreted as a command.

Setting HOME to a junction without spaces does NOT fix the issue — Claude Code resolves the real path internally (likely from USERPROFILE or APPDATA) when constructing the snapshot path.

Expected Behavior

Bash tool should work without errors regardless of whether the Windows username contains spaces.

Actual Behavior

Every Bash command outputs the error /usr/bin/bash: line 1: /c/Users/FirstName: Permission denied before executing the actual command. The command itself runs successfully.

Workarounds Attempted

  • Created NTFS junction to a path without spaces + set HOME env var → did not help
  • Claude Code still uses the original path with spaces for shell snapshot sourcing

View original on GitHub ↗

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