fix: add shell: true to spawnSync on Windows for .cmd launcher#291
fix: add shell: true to spawnSync on Windows for .cmd launcher#291ayu-exorcist wants to merge 1 commit into
Conversation
Node.js spawnSync requires shell: true when executing .cmd batch files on Windows; without it the npm thin-installer shim throws EINVAL. Resolves #289
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes a Windows install/runtime failure when invoking Codegraph via npm/npx by adjusting how the npm shim spawns the bundled executable, and documents the fix in the changelog.
Changes:
- Run
spawnSyncwithshell: trueon Windows to allow executing.cmdfiles. - Add a changelog entry describing the Windows
EINVALfix and linking the related issue.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/npm-shim.js | Adjusts spawnSync options to use a shell on Windows so .cmd invocation works. |
| CHANGELOG.md | Documents the Windows EINVAL fix and references issue #289. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| var res = childProcess.spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' }); | ||
| var res = childProcess.spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit', shell: process.platform === 'win32' }); |
| ### Fixed | ||
| - **Windows `EINVAL` via npm/npx.** The thin-installer shim used `spawnSync` to | ||
| launch the bundled `codegraph.cmd` on Windows, which throws `EINVAL` when | ||
| `shell: true` is omitted (Node.js requires a shell to execute `.cmd` batch | ||
| files). Windows installs via `npm i -g` or `npx` now work. Resolves | ||
| [#289](https://github.com/colbymchenry/codegraph/issues/289). | ||
|
|
||
| ## [0.9.1] - 2026-05-21 |
|
Thanks a lot for this @ayu-exorcist — your diagnosis is spot on, and you caught the We ended up fixing this in #292 (now merged, shipping in 0.9.2) with a slightly different approach, so I'm closing this one as superseded. Why we didn't go with Instead, #292 skips the Really appreciate you taking the time to report and fix this — hope to see more PRs from you. 🙌 |
Node.js
spawnSyncrequiresshell: truewhen executing.cmdbatch files on Windows; without it the npm thin-installer shim throwsEINVALwhen runningcodegraph -v(or any command) vianpm i -gornpx.Fixes #289