claude-code - 💡(How to fix) Fix [BUG] StatusLine command exits 126 when spawned by Claude Code, exit 0 when invoked manually (Windows / Git Bash)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

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").

Error Messages/Logs

[WARN] StatusLine ["C:/Program Files/Git/bin/bash.exe" C:/Users/<user>/.claude/scripts/statusline.sh] completed with status 126 7. Run claude --debug 2> debug.txt then grep -i statusline debug.txt — you'll see the exit 126 WARN.

Fix Action

Fix / Workaround

Workaround: Use the /context slash command for manual context-fill checks.

Code Example

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

---

{
     "statusLine": {
       "type": "command",
       "command": "\"C:/Program Files/Git/bin/bash.exe\" C:/Users/<user>/.claude/scripts/statusline.sh"
     }
   }

---

#!/usr/bin/env bash
   exec "C:/Users/<user>/.local/bin/uv.exe" run "$(dirname "$0")/statusline.py"
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. On Windows with Git for Windows installed, configure ~/.claude/settings.json with the following statusLine block:
   {
     "statusLine": {
       "type": "command",
       "command": "\"C:/Program Files/Git/bin/bash.exe\" C:/Users/<user>/.claude/scripts/statusline.sh"
     }
   }
  1. Create ~/.claude/scripts/statusline.sh:
   #!/usr/bin/env bash
   exec "C:/Users/<user>/.local/bin/uv.exe" run "$(dirname "$0")/statusline.py"
  1. Create a statusline.py that reads JSON from stdin and prints a single status line.

  2. Ensure the script has LF line endings (verified CR count: 0, LF count: 24).

  3. Launch Claude Code.

  4. Observe: no statusline appears at the bottom of the UI.

  5. Run claude --debug 2> debug.txt then grep -i statusline debug.txt — you'll see the exit 126 WARN.

  6. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING