Repository navigation
Fix Bun installs getting npm self-update hints (#1621) - #1622
Conversation
Assisted-by: Claude Code:claude-opus-5-5
`socket-patch --update` on a copy installed with Bun said it was "managed by npm" and suggested an npm command. For a `bun add -g` install that command is a no-op, and in a Bun project `npm install` writes a stray package-lock.json and breaks the next `bun install --frozen-lockfile`. The passive update notice showed the same wrong hint. Bun installs are now labelled "bun" and told to run: - `bun add -g @socketsecurity/socket-patch@latest` for Bun's global store (`$BUN_INSTALL/install/global`), - `bun add @socketsecurity/socket-patch@latest` in a project with bun.lock / bun.lockb or Bun's isolated `node_modules/.bun` store, - `bunx @socketsecurity/socket-patch@latest …` for bunx's cache dir. Fixes #1621 Assisted-by: Claude Code:claude-opus-5-5
A bunx cache dir is now recognized by its name even when it holds no package.json (which would otherwise read as a global prefix and get `bun add -g`). A project-only `bunx-...` name no longer matches: the uid part must be numeric, as bunx writes it. A `.bun` or `.pnpm` store in the binary's path now outranks a lockfile left beside the project, so a project that moved from pnpm to Bun and still has pnpm-lock.yaml is told to use Bun. Refs #1621 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 26461c3. Configure here.
|
Ready for review (burn-down agent).
Slack announcement could not be sent this run (no Slack send tool available); the next run will retry. Generated by Claude Code |
The merge queue dropped this PR because
`pipenv::pipenv_pylock_projects_wire_what_pipenv_installs` failed in the
e2e_vex_build pipenv leg. uv 0.13.2+ refuses the `environments = []`
pylock that Pipenv 2026.8.0 writes ("The target environment is not
supported by the lockfile"), and setup-uv without `version:` installs
the newest uv. main's nightly is red for the same reason.
This is the same pin #1639 adds to ci.yml and pipenv-compatibility.yml.
It changes nothing once #1639 lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016akFSbKa8ztJC4jji31cAn
|
The merge queue dropped this PR (CI_FAILURE) because a check failed that has nothing to do with this PR's code.
The PR needs to be added back to the merge queue once CI is green on Generated by Claude Code |
|
Wenxin Jiang (@Wenxin-Jiang) this changed after your approval (on Besides merges from main, the only new commit is 251cd21: the CI-only uv pin from #1639 ( If that's fine with you, re-approving Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1621
Summary
socket-patch --update(and the passive update notice) told Bun users that the binary was "managed by npm" and gave them an npm command. For abun add -ginstall,npm update -gis a no-op. In a Bun project,npm install …@latestwrites a straypackage-lock.json, leavesbun.lockstale, and breaks the nextbun install --frozen-lockfile. Bun installs are now labelledbunand get Bun's own command:bun add -g…/install/global/node_modules/…($BUN_INSTALL, default~/.bun)bun add -g @socketsecurity/socket-patch@latest(bun update -gkeeps the exact pinned version)bun addin a projectnode_modules/.bun/isolated store in the path, orbun.lock/bun.lockbbeside the outermostnode_modulesbun add @socketsecurity/socket-patch@latestbunxbunx-<numeric uid>-…bunx @socketsecurity/socket-patch@latest …Root cause
update/channel.rs'snode_managerknew only npm, pnpm and vlt ("Anything else is npm, which also covers yarn and Bun (no dedicated hint yet)"). The fix addsBun/Bunxmanagers at that boundary.commands/update.rs(the refusal) andupdate_notifier.rs(the passive notice) both go throughupgrade_hint_for/channel_label_for, so they're both fixed. A path's own store component (.pnpm,.bun) now outranks a lockfile left beside the project, and pnpm's lockfile still outranks Bun's when no store names the manager. CLI_CONTRACT.md's managed-install row is updated to match. The npm/PyPI/gem wrappers have no update hints of their own, so they need no change.Tests
crates/socket-patch-core/src/update/channel.rs):bun_global_installs_get_bun_add_g,bun_project_installs_get_bun_add,bunx_cache_gets_bunx_latest. All 3 failed on main657fce2(cargo test -p socket-patch-core --lib update::channel: 18 passed, 3 failed) and pass with the fix (21 passed).crates/socket-patch-cli/tests/update/self_update_channels_e2e.rs):bun_project_refuses_with_bun_hintandbun_global_refuses_with_bun_hintspawn the real binary from a staged Bun layout and check themanaged by bunrefusal and its hint.cargo test -p socket-patch-cli --all-features --test update: 65 passed.cargo fmt --all -- --checkandcargo clippy --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-core --all-features --lib: 6537 passed. 4 failed, all permission-injection tests (copy_tree,vlt_heal,pypi_poetry,pypi_requirements) that chmod a dir to 0o555 and expect a write to fail. The agent container runs as root, which ignores that. They're unrelated to this diff, and CI runs as non-root.cargo test --workspacerun didn't fit this container's disk allowance (the target dir passed 20 GB). CI covers it.Per-issue checklist:
socket-patch --updateon a Bun-installed copy says "managed by npm" and gives an npm command:npm update -gleaves abun add -ginstall stale, andnpm install …@latestin a Bun project breaksbun install --frozen-lockfile#1621 global (bun add -g):bun_global_installs_get_bun_add_g,bun_global_refuses_with_bun_hintsocket-patch --updateon a Bun-installed copy says "managed by npm" and gives an npm command:npm update -gleaves abun add -ginstall stale, andnpm install …@latestin a Bun project breaksbun install --frozen-lockfile#1621 project (text/binary lock, isolated linker):bun_project_installs_get_bun_add,bun_project_refuses_with_bun_hintsocket-patch --updateon a Bun-installed copy says "managed by npm" and gives an npm command:npm update -gleaves abun add -ginstall stale, andnpm install …@latestin a Bun project breaksbun install --frozen-lockfile#1621 bunx cache (scoped and unscoped spec, cache dir missing package.json):bunx_cache_gets_bunx_latest/code-review high
I fixed two findings in
26461c3. (1) A bunx cache dir without a package.json was read as a global prefix. (2) A leftoverpnpm-lock.yamlbeat Bun's own.bunstore. I tightened the bunx name match to a numeric uid in the same commit. Not fixed, as follow-ups outside this PR's scope:node_modulescopy: the lockfile is only looked for beside the outermostnode_modules. pnpm and vlt have the same limit today.pnpm update --recursive --latest. I couldn't verify Bun's equivalent here, so Bun keepsbun add …@latest.BUN_INSTALL_GLOBAL_DIR/ bunfiginstall.globalDirisn't recognized as global.--backend=symlinkinstalls that canonicalize into~/.bun/install/cachehave nonode_modulescomponent and read as Standalone. This predates the PR and applies to every channel heuristic.https://claude.ai/code/session_016akFSbKa8ztJC4jji31cAn
Note
Low Risk
Heuristic-only changes to refusal messaging and upgrade hints for managed installs; no self-update download or binary replacement behavior changes beyond correct manager detection.
Overview
Self-update managed-install detection now recognizes Bun installs (global store, project with
bun.lock/bun.lockbornode_modules/.bun, and bunx cache dirs) instead of labeling them npm and suggesting npm commands that don't work or corrupt lockfiles.node_managerinupdate/channel.rsgainsBun/Bunxwith path heuristics (store components beat stale lockfiles; pnpm lock still wins when no store names the manager). Refusal messages use managed by bun and hints likebun add -g …,bun add …, orbunx …@latest. CLI_CONTRACT.md documents the Bun row; unit and e2e tests cover global, project, and bunx cases.Reviewed by Cursor Bugbot for commit 26461c3. Configure here.
Generated by Claude Code