Skip to content

fix: run package-manager upgrades through a shell on Windows - #1332

Merged
liruifengv merged 1 commit into
mainfrom
fix/windows-upgrade-spawn-einval
Jul 3, 2026
Merged

fix: run package-manager upgrades through a shell on Windows#1332
liruifengv merged 1 commit into
mainfrom
fix/windows-upgrade-spawn-einval

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

Related Issue

No related issue — clear, reproducible bug fix with a focused diff.

Problem

On Windows, both kimi upgrade and the background auto-update fail with:

warning: failed to install @moonshot-ai/kimi-code@<version>: spawn EINVAL

npm/pnpm/yarn are installed as .cmd shims on Windows. Since Node's CVE-2024-27980 fix, child_process.spawn refuses to execute a .cmd/.bat file unless it is launched through a shell, so the install never starts and users have to copy the printed command and run it manually.

What changed

Pass shell: true when spawning the upgrade command on win32, in both the foreground kimi upgrade path and the background auto-install path. The version is a validated semver and the package name is a constant, so the arguments are shell-safe. Other platforms are unaffected (shell stays undefined).

Added a win32 test that drives the process.platform = 'win32' path on the existing macOS/Linux CI (the dedicated Windows CI job is currently disabled), plus a changeset.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

On Windows, npm/pnpm/yarn are .cmd shims. Since Node's CVE-2024-27980 fix, spawning a .cmd/.bat without a shell throws EINVAL, which broke `kimi upgrade` and background auto-install on Windows. Pass shell: true on win32 so the install runs through the shell.
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b1318b6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 3, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@b1318b6
npx https://pkg.pr.new/@moonshot-ai/kimi-code@b1318b6

commit: b1318b6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1318b6884

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +606 to +610
const child = spawn(cmd, [...args], {
detached: true,
stdio: 'ignore',
shell: platform === 'win32' ? true : undefined,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide the detached Windows updater shell

When auto-install runs on Windows, this background path now starts cmd.exe (shell: true) with detached: true and the default windowsHide: false; Windows detached children get their own console window, so a passive update can pop or flash a command window even though stdio is ignored. Please hide this background child, for example by setting windowsHide: true on win32, so the silent updater stays silent.

Useful? React with 👍 / 👎.

@liruifengv
liruifengv merged commit 93f16c3 into main Jul 3, 2026
10 checks passed
@liruifengv
liruifengv deleted the fix/windows-upgrade-spawn-einval branch July 3, 2026 03:03
@github-actions github-actions Bot mentioned this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant