Ralph Loop plugin: stop-hook.sh fails on Windows - cat command not found

Status Fixed / completed
Maintainer reply None cached
Activity 8 comments · opened Jan 7, 2026 · closed Jan 16, 2026

Bug Description

The Ralph Loop plugin's stop-hook.sh fails on Windows with Git Bash because the cat command is not found in PATH when the hook executes.

Error Message

Stop hook error: Failed with non-blocking status code:
  hooks/stop-hook.sh: line 10: cat: command not found

Root Cause

Line 10 of hooks/stop-hook.sh uses:

HOOK_INPUT=$(cat)

When Claude Code executes bash scripts on Windows, the PATH doesn't include Git Bash's /usr/bin directory where cat resides.

Suggested Fix

Use the full path to cat:

HOOK_INPUT=$("/usr/bin/cat")

Environment

  • OS: Windows 10/11
  • Shell: Git Bash
  • Claude Code version: Latest

Workaround

Manually edit the cached hook script:

sed -i '10s/.*/HOOK_INPUT=$("\/usr\/bin\/cat")/' ~/.claude/plugins/cache/claude-plugins-official/ralph-loop/*/hooks/stop-hook.sh

View original on GitHub ↗

8 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/16559
  2. https://github.com/anthropics/claude-code/issues/16377
  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

chashamm · 7 months ago

👎

ccjwc · 7 months ago

Related Windows issue: On Windows with PowerShell, the .sh hook opens in VS Code (or the default .sh file handler) instead of executing.

Root cause: Windows doesn't know how to execute .sh files natively - it defers to file associations.

Workaround: Edit the plugin's hooks.json to explicitly invoke bash:

"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh\""

This relies on bash being in PATH (typically works if Git Bash is installed and added to PATH).

After editing, clear the plugin cache (.claude/plugins/cache/claude-plugins-official/ralph-loop/) and restart Claude Code.

Suggested proper fix: The plugin itself should handle Windows compatibility - either by detecting the platform or by having Claude Code resolve .sh execution automatically on Windows.

Grips001 · 7 months ago

Workaround

For those facing this issue: manually edit the hooks.json file in the plugin cache after installation.

Note: Plugin updates may overwrite this fix.

---

Details

On Windows, the stop hook fails to execute because the hooks.json specifies the shell script path directly without explicitly invoking bash:

"command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh"

Windows does not recognize the #!/bin/bash shebang and instead attempts to open the .sh file with a default application (such as File Explorer or a text editor) rather than executing it.

---

Fix

Explicitly invoke bash in the command:

"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh\""

---

File Location

~/.claude/plugins/cache/claude-plugins-official/ralph-loop/<version>/hooks/hooks.json

---

Full Corrected hooks.json

{
  "description": "Ralph Loop plugin stop hook for self-referential loops",
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh\""
          }
        ]
      }
    ]
  }
}
oinani0721 · 7 months ago

I submitted a comprehensive fix for this issue. PR Ready: https://github.com/anthropics/claude-plugins-official/pull/127 - Fixes PATH (including cat/jq not found), UTF-8 encoding, cygpath, output format, and race conditions. No manual hooks.json editing needed. Tested on Windows 11. See #16377 for details.

oinani0721 · 7 months ago

The "cat command not found" issue is caused by missing PATH in Git Bash subprocess.

Fix: Add this at the beginning of your hook scripts:

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

This also fixes jq, rm, and other command not found errors.

Full solution with all Windows 11 fixes: #9758

Related: #16377 #17257 #14817

hoiung · 7 months ago

Working Solution for Windows

Found a working fix for this issue. The problem is that Claude Code on Windows doesn't execute .sh files through bash - it tries to run them directly, which fails silently.

Root Cause Analysis

  1. CRLF line endings - Windows can introduce CRLF (\r\n) line endings which break bash scripts (bash interprets \r as part of the command)
  2. No bash interpreter - Even with LF endings, Claude Code doesn't automatically run .sh files through bash on Windows
  3. PATH issues - When hooks execute, /usr/bin isn't in PATH, so commands like cat, sed, grep fail

Solution: .cmd Wrapper

Create a stop-hook.cmd file alongside the .sh file:

@echo off
REM Wrapper to run bash script on Windows
"C:\Program Files\Git\bin\bash.exe" "%~dp0stop-hook.sh"

Then update hooks.json to use the .cmd file:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.cmd"
          }
        ]
      }
    ]
  }
}

Additional Fixes Applied to .sh File

  1. Convert line endings to LF:

``bash
sed -i 's/\r$//' stop-hook.sh
``

  1. Add PATH export at top of script (for any remaining PATH issues):

``bash
export PATH="/usr/bin:/bin:$PATH"
``

Suggested Plugin Update

The ralph-loop plugin should ship with both .sh and .cmd files for cross-platform compatibility. The hooks.json could either:

  • Use .cmd on Windows (auto-detected)
  • Or the plugin documentation could note that Windows users need to apply this fix

This solution has been tested and confirmed working on Windows 10/11 with Git Bash.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.