superpowers icon indicating copy to clipboard operation
superpowers copied to clipboard

Windows: SessionStart hook fails due to Claude Code path handling bug

Open cmathew654-dot opened this issue 9 months ago • 8 comments

filed w/ anthropic @ https://github.com/anthropics/claude-code/issues/23204

Summary

The superpowers SessionStart hook fails on Windows with "hook error" message. This is caused by a Claude Code
bug (filed at anthropics/claude-code), but documenting
here for visibility and potential workaround.

Root Cause

Claude Code strips backslashes from ${CLAUDE_PLUGIN_ROOT} when substituting the variable
on Windows.

Expected path: C:\Users\Cyril.claude\plugins\cache\claude-plugins-offic ial\superpowers\4.1.1\hooks\session-start.sh

Actual path passed to bash: C:UsersCyril.claudepluginscacheclaude-plugins-officialsu perpowers4.1.1/hooks/session-start.sh

Error

SessionStart:startup hook error

Debug log shows: /bin/bash: C:UsersCyril.claudepluginscacheclaude-plugins -officialsuperpowers4.1.1/hooks/session-start.sh: No
such file or directory

Workaround

Replace ${CLAUDE_PLUGIN_ROOT} in hooks.json with a
hardcoded Unix-style path:

{
  "command": "/c/Users/USERNAME/path/to/superpowers/hook
s/session-start.sh"
}

Environment

- Windows 11
- Claude Code 2.1.31

cmathew654-dot avatar Feb 04 '26 23:02 cmathew654-dot

Adding the async line worked for me from this

AdamLMark avatar Feb 05 '26 03:02 AdamLMark

Alternative workaround that's more portable

Instead of hardcoding the bash path in hooks.json, you can add bash to your PATH in Claude Code's settings.json:

%USERPROFILE%\.claude\settings.json:

{
  "env": {
    "PATH": "C:\\Program Files\\Git\\bin;C:\\Program Files\\Git\\usr\\bin;%PATH%",
    "MSYS_NO_PATHCONV": "1"
  }
}

Benefits:

  • Works for any Git Bash installation location
  • No need to modify plugin files (which get overwritten on updates)
  • MSYS_NO_PATHCONV=1 prevents path mangling issues
  • More maintainable across different systems

Note: Adjust the Git Bash path if your installation is in a different location.

losjoe avatar Feb 05 '26 13:02 losjoe

Consolidation

This is now the canonical issue for the CLAUDE_PLUGIN_ROOT backslash-stripping bug on Windows.

The following related issues have been closed as duplicates:

  • #389 — SessionStart hook fails on Windows — bash cannot resolve ${CLAUDE_PLUGIN_ROOT} path
  • #399 — Windows: SessionStart hook fails due to CLAUDE_PLUGIN_ROOT path handling
  • #418 — SessionStart hook fails on Windows due to mixed path separators

Status

  • Root cause: Claude Code strips backslashes from ${CLAUDE_PLUGIN_ROOT} when substituting the variable on Windows. This is an upstream Claude Code bug.
  • Upstream issue: https://github.com/anthropics/claude-code/issues/23204
  • Workaround: Replace ${CLAUDE_PLUGIN_ROOT} in hooks.json with a hardcoded Unix-style path

Related fixes already shipped

Two other Windows SessionStart issues have been resolved:

  • 961052e: Added async: true to prevent TUI freeze when hook is slow/fails
  • 038abed: Replaced O(n²) escape_for_json with O(n) bash parameter substitution

This issue remains open until the upstream Claude Code fix lands.

obra avatar Feb 05 '26 19:02 obra

@obra Are you considering merging #421 or will you wait for an upstream fix in Claude Code? Let me know if you need anything before merging the PR.

pedropaulovc avatar Feb 05 '26 20:02 pedropaulovc

+1 — Hitting the same issue on Windows 11, Claude Code 2.1.32, Superpowers 4.1.1.

Error in debug log:

/bin/bash: C:/Users/<user>/.claude/plugins/cache/claude-plugins-official/superpowers/4.1.1/hooks/session-start.sh: No such file or directory

The file exists on disk — it's purely a path resolution issue when Claude Code auto-prepends bash for .sh files on Windows.

Local workaround: edit the cached hooks.json to explicitly call bash with an escaped Windows path:

"command": "bash \"C:\Users\<user>\.claude\plugins\cache\claude-plugins-official\superpowers\4.1.1\hooks\session-start.sh\""

puneet1409 avatar Feb 06 '26 00:02 puneet1409

@obra Could you please reconsider applying the the fix from #421 while we wait for CC upstream fixes? Windows is not a priority for them. For instance, LSP for C# and TS are broken too for >30 days (https://github.com/anthropics/claude-code/issues/15914#issuecomment-3721465887). The fact that you get a constant stream of reports from different users hitting the same issue is a sign that this is a worthwhile fix.

pedropaulovc avatar Feb 07 '26 20:02 pedropaulovc

Better workaround: .cmd wrapper (no hardcoding needed)

Instead of hardcoding the path (which breaks on plugin version updates), you can create a small batch wrapper that resolves the path natively on Windows.

1. Create hooks/session-start.cmd in the superpowers plugin directory:

@echo off
"C:\Program Files\Git\bin\bash.exe" "%~dp0session-start.sh" %*
exit /b

%~dp0 resolves to the directory of the .cmd file itself, so it always finds session-start.sh next to it — no hardcoded paths, no ${CLAUDE_PLUGIN_ROOT} backslash issues.

2. Update hooks/hooks.json — change the command from:

"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh"

to:

"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.cmd"

Claude Code doesn't auto-prepend bash for .cmd files, so the backslash stripping never happens. Windows runs the .cmd natively, which then explicitly calls Git Bash with the correct path.

Why this is better than hardcoding:

  • Survives plugin version changes (no absolute path to break)
  • Works across different Windows usernames/install locations
  • Only 3 lines to add

Note: Plugin auto-updates will overwrite both files, so you'll need to re-apply after updates until the upstream Claude Code bug (anthropics/claude-code#23204) is fixed.

Boysiee avatar Feb 14 '26 14:02 Boysiee

This should be resolved in v4.3.1, which restores the polyglot run-hook.cmd wrapper and renames session-start.sh to an extensionless session-start to avoid Claude Code's .sh auto-detection on Windows.

The wrapper now tries multiple Git Bash locations, falls back to PATH, and exits silently if no bash is found — so it should handle spaces in paths, missing WSL, MSYS edge cases, HCS sandbox routing, and backslash mangling.

Please reopen if v4.3.1 doesn't resolve this for you!

obra avatar Feb 21 '26 19:02 obra