Skip to content

fix(update): detect npm-global install on Windows Git Bash via path f…#1358

Open
AmariahAK wants to merge 1 commit into
MoonshotAI:mainfrom
AmariahAK:main
Open

fix(update): detect npm-global install on Windows Git Bash via path f…#1358
AmariahAK wants to merge 1 commit into
MoonshotAI:mainfrom
AmariahAK:main

Conversation

@AmariahAK

@AmariahAK AmariahAK commented Jul 3, 2026

Copy link
Copy Markdown

Related Issue

Resolve #1356

Problem

On Windows Git Bash (MSYS2), kimi update always reports 'unsupported' even when installed via npm install -g. execFile("npm.cmd", ...) throws EINVAL under MSYS2 — the catch block unconditionally returned 'unsupported'.

The initial fix added a path-based fallback, but Codex review found it was too broad: endsWith('/node_modules/...') matched any node_modules directory (including project-local).

What changed

Two-part fix inside the catch block in detectInstallSource():

  1. Unix/macOS — uses endsWith('/lib/node_modules/...') (already global-specific)
  2. Windows — uses includes('/npm/node_modules/...') guarded by platform === 'win32', which matches the distinctive AppData/Roaming/npm/node_modules/ global path without triggering on project-local installs

Zero subprocess spawns, strictly additive (only activates when npm prefix -g fails).

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.

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 621c90b

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

@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: 20ad0b2349

ℹ️ 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 thread apps/kimi-code/src/cli/update/source.ts Outdated
…allback

When execFile('npm.cmd', ...) throws EINVAL on Windows Git Bash/MSYS2,
detectInstallSource() now falls back to a path-based heuristic before
returning 'unsupported'. Uses a Windows-specific npm/node_modules/
pattern (platform-guarded) alongside the existing /lib/node_modules/
check instead of a broad node_modules/ suffix, preventing false
matches on project-local installs.

Fixes MoonshotAI#1356
@AmariahAK

Copy link
Copy Markdown
Author

@wbxl2000 & @liruifengv could you kindly review

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.

kimi update fails to detect npm-global install source on Windows Git Bash (EINVAL in execFile)

2 participants