fix(upgrade): add shell option on Windows for .cmd package managers#722
Merged
fix(upgrade): add shell option on Windows for .cmd package managers#722
Conversation
…LI-13T) On Windows, npm/pnpm/yarn are .cmd batch files. child_process.spawn() without shell: true cannot execute .cmd files, causing ENOENT. Add shell: process.platform === "win32" to all spawn() calls in upgrade.ts so cmd.exe resolves .cmd wrappers correctly. This fixes both upgrade execution and legacy installation method detection on Windows (including nvm-managed Node.js).
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
|
Contributor
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1596 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.30% 95.31% +0.01%
==========================================
Files 232 232 —
Lines 34035 34041 +6
Branches 0 0 —
==========================================
+ Hits 32436 32445 +9
- Misses 1599 1596 -3
- Partials 0 0 —Generated by Codecov Action |
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.
Summary
Fixes CLI-13T —
UpgradeError: npm failed: spawn npm ENOENTOn Windows,
npm/pnpm/yarnare.cmdbatch files.child_process.spawn()withoutshell: truecannot execute.cmdfiles, causing ENOENT. This affects users who installed the CLI via npm under nvm (or similar Node.js version managers) on Windows.Changes
shell: process.platform === "win32"to all threespawn()calls insrc/lib/upgrade.ts(runCommand,executeUpgradeHomebrew,executeUpgradePackageManager)runCommandJSDoc to document the Windows.cmdissuetest/isolated/brew-upgrade.test.tsto capture and assert theshellspawn optionNo behavior change on Linux/macOS — the condition evaluates to
false(the existing default).