fix: detect npm global installs in update upgrade suggestion#120
Merged
fix: detect npm global installs in update upgrade suggestion#120
Conversation
The npm path detection only checked for `/npm/` and `/node_modules/.bin/`, missing common npm global prefix paths like `~/.npm-global/`. When path detection failed, the env-based fallback would find `BUN_INSTALL` (set if bun is installed at all) and incorrectly suggest `bun add -g` instead of `npm i -g`. Add `/.npm-global/` and `/.npm/` to the npm path matcher and extract path-matching helpers into named package-level functions with tests. Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
bun add -gfor users who installed vianpm i -gwith a custom prefix (e.g.~/.npm-global/)./.npm-global/and/.npm/in the binary path, so it correctly identifies the install method before falling through to env-based detection (which was matchingBUN_INSTALL).Test plan
go test ./pkg/update/passesgo vet ./pkg/update/cleannpm i -g @onkernel/cliwith a custom npm prefix and verify the upgrade suggestion saysnpm i -g @onkernel/cli@latestMade with Cursor
Note
Low Risk
Scoped to upgrade-suggestion heuristics and adds tests; minimal impact beyond how the CLI chooses the displayed upgrade command.
Overview
Fixes install-method detection so
npmglobal installs (including custom prefixes like~/.npm-globaland~/.npm) are identified via binary path matching, avoiding incorrect fallback tobunenv-based detection and ensuring the upgrade banner suggestsnpm i -g @onkernel/cli@latest.Refactors detection into reusable helpers (
installMethodRules,pathMatches*) and extractssuggestUpgradeCommandForMethodfor testability, with new unit tests covering path matchers, rule precedence, and upgrade-command output.Written by Cursor Bugbot for commit 280e56f. This will update automatically on new commits. Configure here.