[BUG] Hooks fail with `bash: C:/Users/<name>: No such file or directory` when Windows 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?
Environment:
- Claude Code v2.1.267
- OS: Windows (Git Bash / MSYS shell)
- Windows username: contains a space (e.g.,
Lucas Costa)
Description:
Every SessionStart:startup hook and every PostToolUse:Read hook fails with:
Failed with non-blocking status code: bash: C:/Users/Lucas: No such file or directory
The error message is truncated exactly at the space in the Windows profile path (C:\Users\Lucas Costa), which is the classic signature of an unquoted variable being split by bash on word boundaries.
Suspected root cause:
The generated shell snapshot file at ~/.claude/shell-snapshots/snapshot-bash-*.sh contains:
[[ -x $_cc_bin ]] || _cc_bin='/c/Users/Lucas Costa/.local/bin/claude.exe'
export PATH='/c/Users/Lucas Costa/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:...'
$_cc_bin is assigned safely here (quoted), but the error text strongly suggests that somewhere in the hook-runner, this variable (or the resulting claude.exe path) is later referenced without quotes, e.g. $_cc_bin ... instead of "$_cc_bin" ..., causing bash to treat everything after the space as a separate argument/command.
This snapshot is re-sourced before every hook invocation, which is consistent with the failure appearing in both SessionStart and PostToolUse:Read.
Steps to reproduce:
- Use a Windows account whose profile folder name contains a space (e.g.,
C:\Users\First Last). - Install/use Claude Code CLI with Git Bash as the shell.
- Start a session, or trigger any tool that fires a
PostToolUsehook (e.g.,Read). - Observe the hook error referencing only the portion of the path before the space.
Expected behavior:
Hooks should succeed regardless of spaces in the Windows username/profile path.
Actual behavior:SessionStart:startup and PostToolUse:Read (and likely other hook events) fail with a non-blocking error every time.
Workaround found:
Reinstalling Claude Code temporarily resolves the issue (regenerates snapshots/paths), but it recurs after the next update.
What Should Happen?
Expected behavior:
Hooks should succeed regardless of spaces in the Windows username/profile path.
Error Messages/Logs
Steps to Reproduce
- Use a Windows account whose profile folder name contains a space (e.g.
C:\Users\First Last). - Install/use Claude Code CLI with Git Bash as the shell.
- Start a session, or trigger any tool that fires a
PostToolUsehook (e.g.Read). - Observe the hook error referencing only the portion of the path before the space.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.267
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Warp
Additional Information
_No response_