fix(windows): Claude Code fails to launch with ENOENT (uv_spawn) - #9
fix(windows): Claude Code fails to launch with ENOENT (uv_spawn)#9Satelius wants to merge 1 commit into
Conversation
On Windows, `where claude` lists the extension-less npm sh shim first. child_process.spawn without a shell uses CreateProcess, which cannot execute that shim, so launching Claude Code fails with `ENOENT: no such file or directory, uv_spawn '...\npm\claude'`. - resolveClaudePath: prefer the .cmd/.exe/.bat candidate from `where` - runClaudeCode: spawn with shell:true on win32 so cmd.exe runs the resolved .cmd launcher Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR updates Windows launching for Claude Code by broadening path resolution across ChangesWindows Claude launch handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Problem
On Windows,
opencode-gofails to launch Claude Code:■ Failed to start Claude Code: ENOENT: no such file or directory, uv_spawn 'C:\Users...\AppData\Roaming\npm\claude'
Even though
claudeis installed and on PATH.Root cause
resolveClaudePath()runswhere claudeand takes the first line. On Windows, npm installs three shims side by side:C:...\npm\claude ← extension-less sh shim (listed FIRST)
C:...\npm\claude.cmd ← Windows batch launcher
C:...\npm\claude.ps1
child_process.spawnwithoutshell: trueusesCreateProcess, which cannot execute the extension-less sh shim. So spawn fails withENOENT— not "file not found", but "no way to execute it".Fix
src/path.ts—resolveClaudePath()now prefers the.cmd/.exe/.batcandidate fromwhereinstead of blindly taking line 0.src/cli.ts—runClaudeCode()spawns withshell: trueon win32, since.cmdbatch files must run throughcmd.exe.Both changes are scoped to
process.platform === "win32"; macOS/Linux behavior is untouched.Verification
tsc --noEmitpasseswhere claudenow resolves to...\claude.cmdclaude.cmd --version→2.1.191 (Claude Code)✅Summary by CodeRabbit