[BUG] StatusLine command exits 126 when spawned by Claude Code, exit 0 when invoked manually (Windows / Git Bash)
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?
The statusLine command configured in ~/.claude/settings.json fails silently on Windows when invoked by Claude Code, but works correctly when invoked manually from PowerShell using the exact same command string. The statusline never renders at the bottom of the Claude Code panel, with no error surfaced in the UI. The failure is visible only in claude --debug output, where it reports exit code 126 ("command found, but not executable").
Other hooks in the same settings.json (Notification, Stop, PreToolUse Bash, PostToolUse Edit/Write) invoking comparable external tools all execute successfully — confirmed by usage_log.jsonl records and audible notification sounds firing on session events. Only statusLine fails. This suggests the issue is specific to how Claude Code spawns the statusLine command, not the environment broadly.
What Should Happen?
Claude Code should invoke the statusLine command with the same process-spawn configuration used for hooks (which work correctly), and the statusline output should render at the bottom of the UI. If statusLine spawning fails, there should be some UI affordance surfacing the failure rather than failing silently.
Error Messages/Logs
claude --debug 2> debug.txt output (relevant lines):
[DEBUG] Using bash path: "C:\Program Files\Git\bin\bash.exe"
...
[WARN] StatusLine ["C:/Program Files/Git/bin/bash.exe" C:/Users/<user>/.claude/scripts/statusline.sh] completed with status 126
Manual invocation of the exact same command from PowerShell succeeds:
PS> '{}' | & "C:/Program Files/Git/bin/bash.exe" C:/Users/<user>/.claude/scripts/statusline.sh
[##--------] 0% ctx
PS> echo "EXIT: $LASTEXITCODE"
EXIT: 0
Steps to Reproduce
- On Windows with Git for Windows installed, configure
~/.claude/settings.jsonwith the following statusLine block:
{
"statusLine": {
"type": "command",
"command": "\"C:/Program Files/Git/bin/bash.exe\" C:/Users/<user>/.claude/scripts/statusline.sh"
}
}
- Create
~/.claude/scripts/statusline.sh:
#!/usr/bin/env bash
exec "C:/Users/<user>/.local/bin/uv.exe" run "$(dirname "$0")/statusline.py"
- Create a
statusline.pythat reads JSON from stdin and prints a single status line.
- Ensure the script has LF line endings (verified CR count: 0, LF count: 24).
- Launch Claude Code.
- Observe: no statusline appears at the bottom of the UI.
- Run
claude --debug 2> debug.txtthengrep -i statusline debug.txt— you'll see the exit 126 WARN.
- Manually invoke the same command from PowerShell with a sample payload — exit 0, expected output.
Investigation already performed:
- Script has LF-only line endings, shebang present and correct.
- settings.json parses as valid JSON.
- All referenced files exist and are readable.
- Instrumented the wrapper to log every invocation — log was never created during Claude Code sessions, consistent with bash exiting 126 during exec rather than during script body.
- hasTrustDialogAccepted: true for the working directory.
- Other hooks using comparable bash/powershell/uv commands from the same settings.json work correctly.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.150 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Subscription: Claude Max
Node: v24.16.0
npm: 11.13.0
Git Bash: 5.3.9(1)-release (x86_64-pc-cygwin), from Git for Windows 2.54.0
PowerShell: 5.1
Suggested investigation areas:
- Does statusLine spawning use a different child-process configuration (environment variables, working directory, file handle inheritance, stdio setup) than hooks spawning?
- Could statusLine spawning be inheriting a more restricted environment that lacks something Git Bash needs to execute the script (e.g., HOME, PATH segments, TMPDIR)?
- Could a UI affordance surface statusline failures? Currently silent except in --debug mode.
Workaround: Use the /context slash command for manual context-fill checks.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗