claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Ralph Wiggum Plugin] Windows 11 Compatibility Fixes for Stop Hook

Open oinani0721 opened this issue 1 month ago โ€ข 1 comments

a## Summary

The Ralph Wiggum plugin stop hook does not work on Windows 11 due to multiple compatibility issues. This issue documents the problems found and provides complete fixes.

Environment

  • OS: Windows 11
    • Terminal: Windows Terminal + PowerShell
      • Git Bash: C:\Program Files\Git\usr\bin\bash.exe

Issues Found and Fixes

Issue 1: WSL bash Path Resolution

Symptom: WSL ERROR: execvpe(/bin/bash) failed: No such file or directory

Root Cause: On Windows, the bash command resolves to WSL bash, but WSL may not be configured.

Fix in hooks.json: Use Git Bash full path

"command": "\"C:\\Program Files\\Git\\usr\\bin\\bash.exe\" ${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh"

Issue 2: PATH Not Complete

Symptom: cat: command not found, jq: command not found

Root Cause: Git Bash subprocess PATH doesn't include /usr/bin.

Fix: Add at beginning of stop-hook.sh:

export PATH="/usr/bin:/bin:/mingw64/bin:$PATH"

Issue 3: Non-ASCII Path Encoding (Chinese, Japanese, etc.)

Symptom: Path with Unicode characters becomes garbled

Fix: Add UTF-8 locale and use cygpath:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
CWD=$(cygpath -u "$CWD" 2>/dev/null || echo "$CWD" | sed 's/\\/\//g')

Issue 4: Incorrect Output Format

Symptom: Stop hook doesn't trigger iteration continuation

Fix: Output to stderr and exit 2:

jq -n ... >&2
exit 2

Issue 5: Multiple Hooks Race Condition

Symptom: rm: No such file or directory

Fix: Use rm -f instead of rm

Test Results

After all fixes applied:

  • Iteration 1 -> 2 -> 3 -> Normal exit SUCCESS
    • W## Summary The Ralph Wiggum plugin stop hook does not work on Windows 11 due to multiple compatibility issues. This issue documents the problems found and provides complete fixes.

Environment

  • OS: Windows 11
    • Terminal: Windows Terminal + PowerShell
      • Git Bash: C:\Program Files\Git\usr\bin\bash.exe

Issues Found and Fixes

Issue 1: WSL bash Path Resolution

Symptom: WSL ERROR: execvpe(/bin/bash) failed: No such file or directory

Root Cause: On Windows, the bash command resolves to WSL bash, but WSL may not be configured.

Fix in hooks.json: Us

oinani0721 avatar Jan 05 '26 18:01 oinani0721

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/14817
  2. https://github.com/anthropics/claude-code/issues/16116
  3. https://github.com/anthropics/claude-code/issues/15128

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and ๐Ÿ‘ the existing issue instead
  • To prevent auto-closure, add a comment or ๐Ÿ‘Ž this comment

๐Ÿค– Generated with Claude Code

github-actions[bot] avatar Jan 05 '26 18:01 github-actions[bot]

This is not a duplicate of the referenced issues.

Key differences:

  1. Complete solution provided - This issue includes a fully tested fix with PR #127 ready for merge

  2. Covers 5 distinct issues comprehensively:

    • PATH fix for Git Bash subprocess environment
    • UTF-8 encoding for non-ASCII paths (Chinese characters)
    • Absolute path handling via cwd extraction
    • cygpath normalization for Windows paths
    • rm -f to avoid race condition errors
  3. The referenced issues only report problems, while this issue provides the actual working fix

The fix has been tested successfully on Windows 11 with Git Bash, including non-ASCII (Chinese) paths.

Please keep this issue open as it serves as the documentation for the comprehensive Windows 11 compatibility fix.

oinani0721 avatar Jan 06 '26 16:01 oinani0721

โœ… Solution Verified Working

I've tested the complete fix and confirmed all issues are resolved:

Test Results (2026-01-15)

/ralph-loop "็ฎ€ๅ•ๆต‹่ฏ•ไปปๅŠก" --max-iterations 2

Output:

  • โœ… Iteration 1/2 executed successfully
  • โœ… Stop hook returned {"decision": "block"} correctly
  • โœ… Iteration 2/2 continued and completed
  • โœ… State file cleaned up properly
  • โœ… No script content displayed

Additional Discovery

Found that plugin cache versions override inline hooks!

Even with a fixed local hook, outdated versions in these locations still execute:

  • ~/.claude/plugins/cache/claude-plugins-official/ralph-wiggum/
  • ~/.claude/plugins/marketplaces/*/plugins/ralph-wiggum/

Solution: Delete all plugin cache directories to use only the fixed inline hook.

Summary of All Fixes Applied

  1. โœ… PATH export: export PATH="/usr/bin:/bin:/mingw64/bin:$PATH"
  2. โœ… UTF-8: export LC_ALL=en_US.UTF-8
  3. โœ… cygpath: Windows path conversion
  4. โœ… Exit code: exit 2 for continuation
  5. โœ… Absolute paths in settings.local.json
  6. โœ… Deleted plugin cache directories
  7. โœ… CLAUDE_CODE_GIT_BASH_PATH environment variable

The PR #127 to claude-code-plugins contains all these fixes. Awaiting merge.

I've also posted a comprehensive guide in #9758 for broader visibility.

oinani0721 avatar Jan 15 '26 09:01 oinani0721