-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: handle WSL bash as default shell on Windows #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughUpdated the SessionStart hook command to attempt converting Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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. 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@hooks/hooks.json`:
- Line 9: The command string in hooks.json currently uses single quotes around
${CLAUDE_PLUGIN_ROOT} inside the wslpath call which prevents environment
variable expansion; update the command so CLAUDE_PLUGIN_ROOT is expanded (e.g.,
use double quotes or no inner quotes) when calling wslpath, ensuring the
resulting path feeds into run-hook.cmd and session-start.sh correctly (refer to
the "command" value, the wslpath invocation, ${CLAUDE_PLUGIN_ROOT}, and
run-hook.cmd/session-start.sh).
|
@coderabbitai The single quotes around Claude Code expands wslpath -u 'C:\Users\Name With Spaces\.claude\plugins\...'The single quotes protect against word splitting when the path contains spaces. Without them: wslpath -u C:\Users\Name With Spaces\...
# Shell splits this into multiple arguments, causing failureWith single quotes, the entire path is treated as a single argument to |
|
Tip For best results, initiate chat on the files or code changes.
Your explanation makes perfect sense:
I appreciate you taking the time to explain Claude Code's variable expansion behavior. This is important context for understanding the correct quoting strategy in this hook system. ✏️ Learnings added
|
When WSL's bash.exe is in PATH (either alone or before Git's bash.exe), Claude Code passes Windows-style paths that WSL bash cannot resolve, causing "No such file or directory" errors. The fix attempts to convert paths using wslpath first, falling back to the original path for non-WSL environments (native Linux/macOS or Windows with Git Bash). To reproduce the original issue: - PATH contains only WSL's bash.exe path, OR - PATH contains both WSL and Git bash.exe paths but WSL comes first Fixes obra#275 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c0833d4 to
3519d03
Compare
|
This looks like it is likely to fail on everything that's not Windows. Have you tested it on Mac OS and Linux? Is it something that we can address inside the polyglot wrapper script? |
Summary
wslpathto convert Windows paths to WSL format, with fallback for non-WSL environmentsProblem
When WSL's bash.exe is in PATH (either alone or before Git's bash.exe), Claude Code passes Windows-style paths that WSL bash cannot resolve, causing "No such file or directory" errors.
How to reproduce
Fixes #275
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.