Skip to content

fix: use double quotes for CLAUDE_PLUGIN_ROOT in SessionStart hook - #585

Merged
obra merged 1 commit into
obra:mainfrom
atian8179:fix/session-start-hook-linux
Mar 11, 2026
Merged

obra merged 1 commit into
obra:mainfrom
atian8179:fix/session-start-hook-linux

Conversation

@atian8179

Copy link
Copy Markdown
Contributor

Problem

The SessionStart hook in hooks/hooks.json fails on Linux with:

bash: line 1: /hooks/run-hook.cmd: No such file or directory

The hook command uses single quotes around ${CLAUDE_PLUGIN_ROOT}:

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

Single quotes prevent shell variable expansion, so CLAUDE_PLUGIN_ROOT is empty and the shell tries to execute /hooks/run-hook.cmd (absolute path from root).

Reported in #577.

Solution

Use escaped double quotes instead of single quotes:

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

Double quotes allow ${CLAUDE_PLUGIN_ROOT} to expand while still properly quoting paths with spaces.

Changes

  • hooks/hooks.json: 1 character change (single → double quotes)

Testing

  • Verified variable expansion works with double quotes on Linux bash
  • No impact on macOS/Windows (double quotes work universally)

Closes #577

Replace single quotes with escaped double quotes around
${CLAUDE_PLUGIN_ROOT} in hooks.json so the shell variable expands
correctly on Linux. Single quotes prevent variable expansion,
causing the hook to fail with 'No such file or directory'.

Closes obra#577
@coderabbitai

coderabbitai Bot commented Mar 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4a2375 and ad716b8.

📒 Files selected for processing (1)
  • hooks/hooks.json

📝 Walkthrough

Walkthrough

The change updates the SessionStart hook command in hooks/hooks.json by replacing single quotes with escaped double quotes around the ${CLAUDE_PLUGIN_ROOT} path reference, enabling proper environment variable expansion on Linux systems.

Changes

Cohort / File(s) Summary
SessionStart Hook Command Quoting
hooks/hooks.json
Changed command quoting from single quotes (which prevent variable expansion) to escaped double quotes (which allow shell variable expansion), fixing the CLAUDE_PLUGIN_ROOT environment variable resolution for the session-start hook.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Single quotes were quite the pest,
Variables trapped, failing the test,
Double quotes now set them free,
${CLAUDE_PLUGIN_ROOT} expands with glee!
The hook springs forth on Linux with cheer! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing double quotes usage for CLAUDE_PLUGIN_ROOT in the SessionStart hook, which is the primary purpose of this PR.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, changes made, and testing performed.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #577: replacing single quotes with escaped double quotes to enable CLAUDE_PLUGIN_ROOT variable expansion on Linux.
Out of Scope Changes check ✅ Passed The PR contains only the single necessary change to hooks/hooks.json (quote style modification) directly addressing the linked issue #577 with no extraneous changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@obra obra added bug Something isn't working hooks Hook system (SessionStart, Stop, etc.) labels Mar 4, 2026
@obra

obra commented Mar 10, 2026

Copy link
Copy Markdown
Owner

Thanks @atian8179! Clean, minimal fix — exactly right.

We verified this on a Windows 11 dev box (NT 10.0.26200.0) with Claude Code 2.1.72. Single quotes fail in cmd.exe regardless of whether the path has spaces. The escaped double quotes work across all combinations (macOS bash, Windows cmd.exe, Windows Git Bash, with and without spaces in the path).

Merged to dev.

— Claude Opus 4.6, Claude Code 2.1.72

@obra
obra merged commit ec26561 into obra:main Mar 11, 2026
vladivis pushed a commit to vladivis/superpowers that referenced this pull request Mar 18, 2026
…/Linux

Use escaped double quotes instead of single quotes around
${CLAUDE_PLUGIN_ROOT} path in hooks.json.

Single quotes fail on Windows (cmd.exe doesn't recognize them as path
delimiters) and on Linux when the shell doesn't expand the variable.

Verified the fix works across all combinations:
- macOS bash, path without spaces: pass
- macOS bash, path with spaces: pass
- Windows cmd.exe, path without spaces: FAILED with single quotes, PASS with double quotes
- Windows cmd.exe, path with spaces: FAILED with single quotes, PASS with double quotes
- Windows Git Bash: pass (both quote styles work here)

Testing was done on a Windows 11 (NT 10.0.26200.0) dev box with
Claude Code 2.1.72 and Git for Windows. The single-quote bug only
manifests when cmd.exe is the executing shell (no Git Bash fallback),
which explains why some users hit it and others don't.

Closes obra#577, closes obra#644.
shihao-hc pushed a commit to shihao-hc/superpowers that referenced this pull request Apr 6, 2026
…/Linux

Use escaped double quotes instead of single quotes around
${CLAUDE_PLUGIN_ROOT} path in hooks.json.

Single quotes fail on Windows (cmd.exe doesn't recognize them as path
delimiters) and on Linux when the shell doesn't expand the variable.

Verified the fix works across all combinations:
- macOS bash, path without spaces: pass
- macOS bash, path with spaces: pass
- Windows cmd.exe, path without spaces: FAILED with single quotes, PASS with double quotes
- Windows cmd.exe, path with spaces: FAILED with single quotes, PASS with double quotes
- Windows Git Bash: pass (both quote styles work here)

Testing was done on a Windows 11 (NT 10.0.26200.0) dev box with
Claude Code 2.1.72 and Git for Windows. The single-quote bug only
manifests when cmd.exe is the executing shell (no Git Bash fallback),
which explains why some users hit it and others don't.

Closes obra#577, closes obra#644.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hooks Hook system (SessionStart, Stop, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SessionStart hook fails on Linux: CLAUDE_PLUGIN_ROOT not expanding

2 participants