Repository navigation
fix: use double quotes for CLAUDE_PLUGIN_ROOT in SessionStart hook - #585
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change updates the SessionStart hook command in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
|
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 |
…/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.
…/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.
Problem
The
SessionStarthook inhooks/hooks.jsonfails on Linux with:The hook command uses single quotes around
${CLAUDE_PLUGIN_ROOT}:Single quotes prevent shell variable expansion, so
CLAUDE_PLUGIN_ROOTis 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:
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
Closes #577