[plugin: ralph-loop] stop-hook.sh #!/bin/bash shebang fails on 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?
Bug
plugins/ralph-loop/hooks/stop-hook.sh in claude-plugins-official uses #!/bin/bash. On Windows, Claude Code runs .sh hooks via Git Bash (C:\Program Files\Git\usr\bin\bash.exe), where bash lives at /usr/bin/bash — there is no /bin/bash symlink. The Stop hook therefore fails on every assistant turn with:
/bin/bash: cannot execute binary file
The failure is non-blocking, but it spams stderr on every Stop event, polluting the user's terminal.
Reproduce
- Windows 10/11 + Claude Code installed
- Enable
ralph-loopplugin (/plugin enable ralph-loop@claude-plugins-official) - Send any prompt → assistant turn ends → Stop hook fires
- Observe
/bin/bash: cannot execute binary filein the hook error feed
Root cause
stop-hook.sh hard-codes #!/bin/bash. This assumes bash is at /bin/bash, which is true on most Linux distros and macOS, but not on:
- Windows + Git Bash (MinGW) →
/usr/bin/bash - Some minimal NixOS / Alpine setups
- Custom Homebrew bash installs
Fix
Change shebang from #!/bin/bash to #!/usr/bin/env bash.
/usr/bin/env is part of POSIX and is the portable form recommended by autoconf, the Filesystem Hierarchy Standard, and cross-platform shell-script style guides. It resolves bash via PATH, so:
- Linux / macOS with bash at
/bin/bash→ still works (env finds it via PATH) - Git Bash on Windows (
/usr/bin/bash) → now works - Nix / Alpine / Homebrew custom bash paths → now works
Zero behavior change on systems where the original shebang already worked.
Diff
--- a/plugins/ralph-loop/hooks/stop-hook.sh
+++ b/plugins/ralph-loop/hooks/stop-hook.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Ralph Loop Stop Hook
# Prevents session exit when a ralph-loop is active
1 file changed, 1 insertion(+), 1 deletion(-).
Related work also surfaced during this debug
While investigating the Windows hook errors, I also found that the hookify plugin's hooks.json calls python3. On Windows with Python.org's installer, only python.exe is registered — python3.exe falls through to the Microsoft Store stub:
Python was not found but can be installed from the Microsoft Store: ms-windows-store://...
I did not propose a python3 → python upstream change because that would break Ubuntu/Debian users who lack the python-is-python3 symlink. The proper fix is more nuanced (Python launcher py.exe, wrapper script, or doc note about App Execution Aliases). Worth a separate issue / discussion if there's interest.
PR
I prepared the one-line shebang fix as a PR but the repo auto-closes external contributions: anthropics/claude-plugins-official#1938. Reproducing the diff here so the team can apply it directly if they'd like.
Environment
- OS: Windows 10 Pro 19045
- Shell used by Claude Code on Windows: Git Bash (
C:\Program Files\Git\usr\bin\bash.exe) - Plugin:
ralph-loop@claude-plugins-official - Symptom-side patched locally on my machine; reporting upstream so other Windows users benefit.
What Should Happen?
Stop hook executes silently when the assistant turn ends. No /bin/bash error spam in the hook error feed.
After the fix (#!/usr/bin/env bash), Git Bash on Windows resolves bash via /usr/bin/bash, the script body runs as designed, and stderr stays clean.
Error Messages/Logs
PreToolUse:Write hook error
PostToolUse:Write hook error
PreToolUse:Read hook error
PostToolUse:Read hook error
PreToolUse:Edit hook error
PostToolUse:Edit hook error
Failed with non-blocking status code: /bin/bash: /bin/bash: cannot execute binary file
Steps to Reproduce
- Use Claude Code on Windows (Git Bash as default shell)
- Enable the ralph-loop plugin:
/plugin enable ralph-loop@claude-plugins-official - Send any prompt and let the assistant turn complete
- Observe stderr in the hook error feed:
/bin/bash: cannot execute binary file
- Inspect
plugins/ralph-loop/hooks/stop-hook.shline 1 — shebang is#!/bin/bash - On Windows + Git Bash, bash is at
/usr/bin/bash, no/bin/bashsymlink exists
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.145 (Claude Code)
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Local workaround applied on my machine: patched cache + marketplace copies of stop-hook.sh to use #!/usr/bin/env bash. Patches survive until next plugin update / git pull from marketplace, hence reporting upstream.
I also opened anthropics/claude-plugins-official#1938 with the same one-line diff but it was auto-closed (repo blocks external PRs). Filing here so an Anthropic team member can pick it up.
Related sibling bug not reported here: hookify plugin's hooks.json calls python3, which on Windows resolves to the Microsoft Store stub. Worth a separate discussion — fix is more nuanced than the shebang change.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗