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

Windows: Plugin hooks using ${CLAUDE_PLUGIN_ROOT} fail to start

Open adamkane opened this issue 1 month ago • 1 comments

Bug Description

On Windows, plugin hooks that use ${CLAUDE_PLUGIN_ROOT} in their command fail with:

Plugin hook "C:\Users\...\hooks\stop-hook.sh" failed to start: The operation was aborted.

Steps to Reproduce

  1. Install a plugin with hooks (e.g., ralph-wiggum@claude-plugins-official)
  2. Plugin's hooks/hooks.json contains:
    {
      "hooks": {
        "Stop": [{
          "hooks": [{
            "type": "command",
            "command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop-hook.sh"
          }]
        }]
      }
    }
    
  3. Trigger the stop hook (end a session)
  4. Error appears: "failed to start: The operation was aborted"

Expected Behavior

The ${CLAUDE_PLUGIN_ROOT} variable should expand to the plugin's cached directory path and the hook should execute.

Actual Behavior

The variable doesn't expand correctly on Windows. The hook runner appears to abort before starting the command.

Workaround

Manually edit the cached plugin's hooks.json to use explicit bash with full path:

{
  "command": "bash C:/Users/USERNAME/.claude/plugins/cache/claude-plugins-official/plugin-name/HASH/hooks/stop-hook.sh"
}

Or register the hook directly in project .claude/settings.json with a relative path:

{
  "hooks": {
    "Stop": [{
      "hooks": [{
        "type": "command", 
        "command": "bash .claude/plugins/plugin-name/hooks/stop-hook.sh"
      }]
    }]
  }
}

Environment

  • OS: Windows 11 (MINGW64_NT-10.0-26200)
  • Shell: Git Bash
  • Claude Code: Latest CLI version
  • Plugin: ralph-wiggum@claude-plugins-official

Suggested Fix

  1. Ensure ${CLAUDE_PLUGIN_ROOT} is expanded before passing to the shell
  2. Use Unix-style paths (forward slashes) on Windows for bash compatibility
  3. Prepend bash to .sh commands automatically on Windows

Additional Context

The hook script itself runs fine when called directly:

echo '{}' | bash "/path/to/stop-hook.sh"  # Works

The issue is in the hook runner's command construction/execution on Windows.

adamkane avatar Jan 03 '26 01:01 adamkane

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11984
  2. https://github.com/anthropics/claude-code/issues/15481
  3. https://github.com/anthropics/claude-code/issues/9758

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 03 '26 01:01 github-actions[bot]

This issue has been automatically closed as a duplicate of #11984.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Jan 06 '26 09:01 github-actions[bot]