[Bug] Hook executor mangles Windows paths - backslashes stripped when expanding ${CLAUDE_PLUGIN_ROOT}
Bug Description
On Windows, the hook executor strips backslashes from paths when expanding ${CLAUDE_PLUGIN_ROOT}, causing hook scripts to fail with "No such file or directory".
Environment
- OS: Windows 11
- Claude Code version: Latest (as of 2026-02-07)
- Plugin: ralph-loop (uses Stop hook)
- Shell: Default Windows environment (Git Bash available)
Steps to Reproduce
- Install the
ralph-loopplugin on Windows - Run
/ralph-loop "Test task" --max-iterations 2 --completion-promise "DONE" - Complete the first iteration and let the stop hook trigger
Expected Behavior
The stop hook should execute successfully, intercepting the exit and feeding the prompt back for the next iteration.
Actual Behavior
The stop hook fails with the following error:
Stop hook error: Failed with non-blocking status code: /bin/bash:
C:UsersYKL.claudepluginscacheclaude-plugins-officialralph-loop2cd88e7947b7/hooks/stop-hook.sh: No such file or directory
Root Cause Analysis
The issue is in how the hook executor resolves and passes paths on Windows:
hooks.jsondefines:"command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh"${CLAUDE_PLUGIN_ROOT}expands to a Windows path:C:\Users\YKL\.claude\plugins\cache\...\ralph-loop\2cd88e7947b7- When the expanded path is passed to the shell, all backslashes are stripped:
- Expected:
C:\Users\YKL\.claude\plugins\cache\...\stop-hook.sh - Actual:
C:UsersYKL.claudepluginscache...stop-hook.sh
Additionally, the executor tries to use /bin/bash which doesn't exist on Windows (Git Bash installs to C:\Program Files\Git\bin\bash.exe).
Impact
This affects all plugins that use hook scripts (.sh) on Windows, not just ralph-loop. Any plugin defining hooks via hooks.json with ${CLAUDE_PLUGIN_ROOT} will have the same path mangling issue.
Suggested Fix
The hook executor should:
- Properly handle Windows-style paths (backslashes) when expanding variables
- Detect the platform and use an appropriate shell (e.g.,
bash.exefrom Git for Windows, or PowerShell) - Alternatively, convert Windows paths to forward slashes before passing to bash (bash on Windows accepts
/c/Users/...style paths)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗