Skip to content

SessionStart hook fails on Windows: CLAUDE_PLUGIN_ROOT backslashes mangled by bash #487

@tytytyparker-cloud

Description

@tytytyparker-cloud

Summary

The SessionStart hook in hooks/hooks.json fails on Windows because ${CLAUDE_PLUGIN_ROOT} expands with backslashes, which bash interprets as escape characters, mangling the path.

Error

Hook SessionStart:startup (SessionStart) error:
/bin/bash: C:Usersgtypa.claudepluginscacheclaude-plugins-officialsuperpowers4.3.0/hooks/session-start.sh: No such file or directory

Root Cause

  1. Claude Code expands ${CLAUDE_PLUGIN_ROOT} to Windows path: C:\Users\gtypa\.claude\plugins\cache\...
  2. This path is passed to /bin/bash as a command argument
  3. Bash interprets \U, \g, \p, etc. as escape sequences
  4. Result: C:Usersgtypa.claudepluginscache... — backslashes eaten, path broken

Environment

  • OS: Windows 11
  • Claude Code: 2.1.31
  • Superpowers: 4.3.0
  • Bash: Git Bash (C:\Program Files\Git\bin\bash.exe)

Affected Code

hooks/hooks.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|resume|clear|compact",
        "hooks": [
          {
            "type": "command",
            "command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh",
            "async": false
          }
        ]
      }
    ]
  }
}

Suggested Fixes

Option 1: Path conversion in session-start.sh

The script already uses SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" to derive the plugin root — this works correctly when bash can actually find the script. The problem is upstream.

Option 2: PowerShell wrapper on Windows

Detect platform and use PowerShell-based hooks on Windows, which handle native paths correctly.

Option 3: Request Claude Code fix

This may actually be a Claude Code bug — ${CLAUDE_PLUGIN_ROOT} should be converted to forward slashes before being passed to bash on Windows. Forward slashes work fine in Git Bash paths.

Workaround

Disabled the hook by renaming the key in hooks.json:

"_DISABLED_SessionStart_WINDOWS_PATH_BUG": [...]

This prevents the error but loses the SessionStart functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions