fix: Windows CLI backends fail through npm shims#101378
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6e26b699d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| execPath: | ||
| process.platform === "win32" | ||
| ? resolveWindowsExecutablePath("node", params.env ?? process.env) | ||
| : undefined, |
There was a problem hiding this comment.
Resolve Node relative to the npm shim
When a Windows backend is configured as an absolute npm .cmd path (for example C:\Program Files\nodejs\gemini.cmd) and the service PATH does not include that directory, this resolves the unwrapped JS entrypoint with node searched only from params.env/process.env. npm cmd-shims first try %dp0%\node.exe, so the wrapper would still work with the adjacent Node installation, but the new direct path can fail with ENOENT or run a different Node. Preserve the shim's own adjacent-Node resolution before bypassing it.
Useful? React with 👍 / 👎.
|
Land-ready at exact head
Known proof gaps: none. |
|
Merged via squash.
|
* fix(process): resolve Windows npm CLI shims directly Co-authored-by: wendy-chsy <[email protected]> * docs(changelog): note Windows CLI shim fix * docs(process): explain Windows shim boundary * chore: keep release changelog owner-only * test(process): isolate Windows shim resolution * fix(process): classify Windows forwarding shims safely --------- Co-authored-by: wendy-chsy <[email protected]>
* fix(process): resolve Windows npm CLI shims directly Co-authored-by: wendy-chsy <[email protected]> * docs(changelog): note Windows CLI shim fix * docs(process): explain Windows shim boundary * chore: keep release changelog owner-only * test(process): isolate Windows shim resolution * fix(process): classify Windows forwarding shims safely --------- Co-authored-by: wendy-chsy <[email protected]>
* fix(process): resolve Windows npm CLI shims directly Co-authored-by: wendy-chsy <[email protected]> * docs(changelog): note Windows CLI shim fix * docs(process): explain Windows shim boundary * chore: keep release changelog owner-only * test(process): isolate Windows shim resolution * fix(process): classify Windows forwarding shims safely --------- Co-authored-by: wendy-chsy <[email protected]>
* fix(process): resolve Windows npm CLI shims directly Co-authored-by: wendy-chsy <[email protected]> * docs(changelog): note Windows CLI shim fix * docs(process): explain Windows shim boundary * chore: keep release changelog owner-only * test(process): isolate Windows shim resolution * fix(process): classify Windows forwarding shims safely --------- Co-authored-by: wendy-chsy <[email protected]> (cherry picked from commit 7b366e1)
Closes #98573
Closes #92054
Closes #91489
Supersedes #98952, with contributor credit to @wendy-chsy.
What Problem This Solves
Fixes an issue where Windows users running globally installed Gemini CLI or Claude Code backends could fail to start the CLI because Node does not execute npm
.cmdlaunchers directly.Why This Change Was Made
Resolve standard Windows npm launchers through the existing generic spawn-program resolver, then execute their Node entrypoint or native executable directly. This keeps provider policy out of the process supervisor and preserves structured arguments, including Gemini prompts containing shell metacharacters, without opting into
shell: trueorcmd.exeparsing.User Impact
Gemini CLI and Claude Code backends installed through npm now start on Windows while prompts and arguments remain intact. Existing package-manager shim handling remains unchanged when PATH probing cannot resolve a wrapper.
Evidence
tbx_01kwxdx905kdbyrwcjgr2nrmnm): 21/21 child-adapter tests, 6/6 Windows-spawn tests, and 3/3 Docker-invocation sibling tests.check:changedpassed on the same Testbox, including tsgo, all oxlint shards, import-cycle checks, package guards, and generated-surface checks.cmd-shimlauncher shape for Gemini's JavaScript entrypoint and Claude's native executable, including a prompt with&,|,>, and%.cbx_4f9050b097eb, runrun_4b48efb2298b, using Node 24.18.0: 4/4 targeted npm-shim and custom-wrapper tests passed.