Plugins with bash scripts break on Windows due to CRLF line endings and path resolution
Bug Description
Plugins that include .sh shell scripts fail on Windows due to two issues:
1. CRLF Line Endings in Shell Scripts
When plugins are installed on Windows, git clone converts LF line endings to CRLF (due to core.autocrlf=true default). This causes the shebang line #!/bin/bash to become #!/bin/bash\r, which makes bash unable to find the interpreter:
Stop hook error: Failed with non-blocking status code: /bin/bash:
C:/Users/.../hooks/stop-hook.sh: No such file or directory
2. Hook System Path Resolution
The hook system invokes /bin/bash with Windows-style C:/ paths. On systems where /bin/bash resolves to WSL bash (instead of Git Bash), these paths cannot be resolved, causing "No such file or directory" errors even when the files exist.
Affected Plugins
Any plugin using .sh scripts in hooks or command templates, including:
- ralph-loop (official) -
stop-hook.shin hooks,setup-ralph-loop.shin command template - learning-output-style (official) -
session-start.shin hooks - claude-scientific-writer -
review_poster.shin skills - document-skills (anthropic-agent-skills) -
init-artifact.sh,bundle-artifact.shin skills
Steps to Reproduce
- Install Claude Code on Windows 11 with Git for Windows (default
core.autocrlf=true) - Install any plugin that uses
.shscripts (e.g.,ralph-loop) - Trigger the hook or command that invokes the
.shscript - Observe "No such file or directory" error
Expected Behavior
Plugins should work out of the box on Windows without manual fixes.
Suggested Fixes
- Set
core.autocrlf=falsewhen cloning plugin repos - prevents CRLF conversion for.shfiles - Or add a
.gitattributesto plugin repos with*.sh text eol=lfto force LF on all platforms - Or convert
.shfiles to LF after download in the plugin installer - Or use Node.js instead of bash for hooks/scripts since Node.js handles Windows paths natively and is guaranteed to be available (Claude Code runs on Node.js)
Workaround
Converting .sh files to LF line endings after install:
node -e "const fs=require('fs'); const f='path/to/script.sh'; fs.writeFileSync(f, fs.readFileSync(f,'utf8').replace(/\r\n/g,'\n'))"
Or rewriting hooks in Node.js and updating hooks.json to use node instead of the .sh script.
Environment
- Windows 11 Pro 10.0.26200
- Git for Windows (default
core.autocrlf=true) - Claude Code (latest)
- Node.js v22.20.0
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗