fix: fallback for missing process.env.ComSpec on Windows#137
Merged
owlstronaut merged 2 commits intonpm:mainfrom Aug 28, 2025
Merged
fix: fallback for missing process.env.ComSpec on Windows#137owlstronaut merged 2 commits intonpm:mainfrom
owlstronaut merged 2 commits intonpm:mainfrom
Conversation
3241d57 to
76f4d45
Compare
Contributor
|
You can ignore the CodeQL failure. Next step is for me to actually review it |
owlstronaut
approved these changes
Aug 28, 2025
Merged
owlstronaut
pushed a commit
that referenced
this pull request
Aug 28, 2025
🤖 I have created a release *beep* *boop* --- ## [8.0.3](v8.0.2...v8.0.3) (2025-08-28) ### Bug Fixes * [`c12e015`](c12e015) [#137](#137) fallback for missing process.env.ComSpec on Windows (#137) (@SongMinQQ) ### Chores * [`ddef6b2`](ddef6b2) [#133](#133) postinstall workflow updates (#133) (@owlstronaut) * [`32390d6`](32390d6) [#136](#136) bump @npmcli/template-oss from 4.24.4 to 4.25.0 (#136) (@dependabot[bot], @npm-cli-bot) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
What / Why
issue No. #131
On Windows, some environments don’t expose process.env.ComSpec.
When that happens, the shell selection logic ends up passing undefined to child_process.spawn(), throwing ERR_INVALID_ARG_TYPE (“file” must be a string).
This PR updates the shell resolution so that on win32 we fallback to "cmd.exe" when process.env.ComSpec is missing, while preserving existing behavior on:
non-Windows (sh) and
Windows when ComSpec is set (still honored).
Rationale: cmd.exe is the standard Windows shell and is present by default. This change prevents crashes in real-world setups without altering behavior for users who explicitly define ComSpec.
Change summary
Update shell selection:
Add/adjust tests to cover the “missing ComSpec” case on Windows.
Tests
References
Prior attempt on npm/cli was closed with a maintainer note that this logic lives in @npmcli/promise-spawn (npm vendors this dependency).
GitHub