Skip to content

fix: detect npm global installs in update upgrade suggestion#120

Merged
rgarcia merged 1 commit intomainfrom
fix/npm-global-install-detection
Feb 24, 2026
Merged

fix: detect npm global installs in update upgrade suggestion#120
rgarcia merged 1 commit intomainfrom
fix/npm-global-install-detection

Conversation

@rgarcia
Copy link
Contributor

@rgarcia rgarcia commented Feb 24, 2026

Summary

  • Fix update check suggesting bun add -g for users who installed via npm i -g with a custom prefix (e.g. ~/.npm-global/).
  • The npm path matcher now also checks for /.npm-global/ and /.npm/ in the binary path, so it correctly identifies the install method before falling through to env-based detection (which was matching BUN_INSTALL).
  • Refactored path-matching helpers into named package-level functions and added tests.

Test plan

  • go test ./pkg/update/ passes
  • go vet ./pkg/update/ clean
  • Manual: install via npm i -g @onkernel/cli with a custom npm prefix and verify the upgrade suggestion says npm i -g @onkernel/cli@latest

Made 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 npm global installs (including custom prefixes like ~/.npm-global and ~/.npm) are identified via binary path matching, avoiding incorrect fallback to bun env-based detection and ensuring the upgrade banner suggests npm i -g @onkernel/cli@latest.

Refactors detection into reusable helpers (installMethodRules, pathMatches*) and extracts suggestUpgradeCommandForMethod for 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.

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>
@rgarcia rgarcia merged commit f4fdc8a into main Feb 24, 2026
2 checks passed
@rgarcia rgarcia deleted the fix/npm-global-install-detection branch February 24, 2026 19:59
Copy link
Contributor

@Sayan- Sayan- left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

2 participants