Plugin hooks fail on Windows: wrong path format and CRLF line endings in shell scripts
Description
Plugin stop/session-end hooks fail on Windows because of two issues in the plugin system:
1. Windows-style paths in hooks.json
The plugin installer generates hooks.json with Windows backslash paths (e.g., C:\Users\...), but hooks are executed via /bin/bash. Bash cannot resolve these paths, resulting in:
Stop hook error: Failed with non-blocking status code: /bin/bash:
C:Usersaitra.claudepluginsmarketplacesdesign-pluginsdesign-and-refinescriptscleanup-check.sh: No such file or directory
The backslashes are consumed as escape characters, producing a mangled path. The correct format for bash on Windows should be /mnt/c/Users/... or at minimum C:/Users/....
2. CRLF line endings in downloaded shell scripts
Plugin shell scripts (e.g., cleanup-check.sh) are downloaded with Windows CRLF line endings, causing:
cleanup-check.sh: line 2: $'\r': command not found
cleanup-check.sh: line 5: $'\r': command not found
cleanup-check.sh: line 32: syntax error: unexpected end of file
3. Version path not updated on upgrade
When a plugin upgrades (e.g., from 0.1.0 to 1.1.0), the cached hooks.json may still reference the old version directory path, causing:
/mnt/c/Users/aitra/.claude/plugins/cache/design-plugins/design-and-refine/0.1.0/scripts/cleanup-check.sh: No such file or directory
Affected Plugin
design-and-refine (but likely affects any plugin with shell-based hooks on Windows)
Environment
- OS: Windows 11 Pro 10.0.26100
- Shell: Git Bash (via
/bin/bash) - Claude Code: CLI
Steps to Reproduce
- Install a plugin with shell-based hooks (e.g.,
design-and-refine) on Windows - Start a Claude Code session
- End the session or stop Claude Code
- Observe stop hook errors
Expected Behavior
hooks.jsonshould use bash-compatible paths (/mnt/c/...or forward slashes) when the hook executor is bash- Downloaded
.shscripts should have LF line endings, or be converted automatically - Plugin version upgrade should update all cached path references
Workaround
Manually fix the hooks.json files:
- Change paths from
C:\Users\...to/mnt/c/Users/... - Convert
.shscripts to LF:tr -d '\r' < script.sh > script.tmp && mv script.tmp script.sh
These fixes need to be reapplied after every plugin upgrade.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗