fix: route through cmd /c on Windows to fix ENOENT when spawning claude#5
Open
zerojarvis wants to merge 1 commit into
Open
fix: route through cmd /c on Windows to fix ENOENT when spawning claude#5zerojarvis wants to merge 1 commit into
zerojarvis wants to merge 1 commit into
Conversation
Node child_process.spawn(claude) fails with ENOENT on Windows because npm installs claude as a .cmd batch file, which cannot be executed directly without shell:true. Routing through cmd /c claude passes all arguments as discrete array elements, avoiding the quoting and newline pitfalls of shell:true. Adds a test asserting the Windows code path and updates the platform-agnostic spawn-argument tests to match either command name.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
child_process.spawn('claude', ...)fails withENOENTbecause npm installsclaudeas a.cmdbatch file that Node cannot execute directly withoutshell: true.ClawdCommit shows this error in VS Code:
...even when
claudeis correctly installed and works in the terminal.Root cause
npm on Windows creates three shims for any global package:
spawnusable?claudeclaude.cmdshell:trueorcmd /cclaude.ps1.PS1not in default PATHEXTNode's
spawn(withoutshell:true) finds the extensionless Unix script and fails with ENOENT.Fix
On Windows, route through
cmd /c claudeinstead of spawningclaudedirectly. This letscmd.exeresolve the.cmdshim natively. Arguments are still passed as a discrete array (not a concatenated shell string), which avoids the quoting and newline pitfalls ofshell: true.Tests
routes through cmd /c on Windowstest that stubsprocess.platformtowin32expect.any(String)for the command name so they pass on both Windows and non-Windows CIVerified on
Windows 11, Node v24.16.0, Claude Code CLI v2.1.177