Repository navigation
Conversation
…ups, and * find_best_version (and the minimum-release-age variant) diverged from npm in three ways: - The exact-version fast path fired on the first comparator of the first || alternative, so the rest of the group was never evaluated. - The stable list was scanned first and prereleases only as a fallback, so a satisfying prerelease higher than the best satisfying stable was never chosen, and a latest dist-tag that satisfies a prerelease range was only honored if it equaled the range's left version. - '*' never considered the latest dist-tag, so packages with only prerelease versions failed to resolve. npm (npm-pick-manifest) prefers a satisfying latest dist-tag, treats '*' as latest, and otherwise picks the highest satisfying version overall.
|
Updated 11:53 AM PT - Jun 27th, 2026
❌ @robobun, your commit d5bf62b has 1 failures in
🧪 To try this PR locally: bunx bun-pr 32843That installs a local version of the PR into your bun-32843 --bun |
|
Status: all three npm resolution divergences are fixed in CI: the diff is green on every lane that ran tests. Build 65475 had 72 lanes pass, red only on a |
|
Found 3 issues this PR may fix:
🤖 Generated with Claude Code |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughRefactors npm version resolution in Changesnpm version resolution
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/install/npm.rs`:
- Around line 1824-1873: The `find_version`/version-selection path in
`src/install/npm.rs` drops the dist-tag `latest` candidate when it is filtered
out for age and then falls back without considering prereleases unless
`Flags::PRE` is set. Update the logic around the `group.is_star()` check and the
subsequent `search_version_list` calls so `*` continues to use the `latest`
fallback behavior even when `latest` is too recent, and ensure an older
acceptable prerelease can still be selected instead of returning
`AllVersionsTooRecent`. Keep the fix localized to the
`search_version_list`/`prereleases` selection flow and preserve the existing
`prerelease_is_higher` ordering rule.
In `@test/cli/install/bun-install-version-resolution.test.ts`:
- Around line 48-58: The install test is reading and returning lockfile-derived
resolution data even when bun install fails, which hides the real diagnostics.
In the test around the resolved map setup, guard on the exit code before any
bun.lock parsing or Object.fromEntries work, and fail the test with
stdout/stderr when the command does not succeed. Keep the early exit-code check
in the install CLI test flow so failures surface instead of producing an empty
resolved result.
- Around line 1-4: The install CLI test file is missing the standard
long-running test timeout setup, which can cause failures in slow debug/ASAN
runs. Add the established install-test default timeout at file startup in this
test module, alongside the existing imports and before the test cases, using the
same pattern used by other files under test/cli/install/ so the suite inherits
the 5-minute limit.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: af47b379-16ce-48f9-bdfe-98d7d1f570cc
📒 Files selected for processing (2)
src/install/npm.rstest/cli/install/bun-install-version-resolution.test.ts
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
'>=0.0.0', '>=0', and 'x' parse to the same shape as '*' but npm does not give them the latest dist-tag preference; track the literal in a parse flag instead of using the structural is_star().
|
I checked each of the three suggested issues against npm 11 and this branch before adding any "Fixes" lines, and none of them is actually closed by this PR, so I am not linking them:
|
…e-filtered For '*' with minimumReleaseAge, an entirely too recent latest channel previously returned AllVersionsTooRecent even when an old enough version existed in the other list. Also surface the newest age-filtered version when the two scans disagree so the minimum-release-age diagnostics stay accurate.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/install/npm.rs (1)
1860-1908: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winTrack the highest filtered candidate across both scans.
This block assumes
newest_filteredalready holds the newest filtered match overall. It doesn’t: the release scan runs first, so a filtered release can stick even when the prerelease scan later sees a higher filtered prerelease. For a range like<3.0.0-beta.2, that can leavebest = 3.0.0-alpha.1butnewest_filtered = 2.5.0, so Lines 1893-1908 returnFoundinstead ofFoundWithFilterand drop the minimum-release-age signal for the actual newest satisfying version. Please merge filtered candidates by semver order instead of “first one wins.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/install/npm.rs` around lines 1860 - 1908, The version-selection logic in the npm install search is not merging filtered candidates from both release and prerelease scans, so `newest_filtered` can stay stuck on the first scan’s result instead of the highest satisfying version overall. Update the `search_version_list` / `best` handling in this block so `newest_filtered` is compared and replaced by semver order across both scans, not “first one wins,” and ensure the final `FoundWithFilter` decision uses the merged highest filtered candidate from `FindVersionResult`/`found()` before returning.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/install/npm.rs`:
- Around line 1860-1908: The version-selection logic in the npm install search
is not merging filtered candidates from both release and prerelease scans, so
`newest_filtered` can stay stuck on the first scan’s result instead of the
highest satisfying version overall. Update the `search_version_list` / `best`
handling in this block so `newest_filtered` is compared and replaced by semver
order across both scans, not “first one wins,” and ensure the final
`FoundWithFilter` decision uses the merged highest filtered candidate from
`FindVersionResult`/`found()` before returning.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b0289bb7-cfdb-4305-bc80-351ff6e8ce99
📒 Files selected for processing (3)
src/install/npm.rssrc/semver/SemverQuery.rstest/cli/install/bun-install-version-resolution.test.ts
'*' and '>=0.0.0' parse to the same comparators but resolve differently, so dependency change detection has to tell them apart.
There was a problem hiding this comment.
All my earlier feedback has been addressed and this pass found nothing new, but this reworks the core bun install version-selection path (and semver query equality), so it should get a maintainer's eyes before merge.
Extended reasoning...
Overview
This PR changes how bun install selects a version from a package manifest to match npm's behavior for three classes of ranges: prerelease-bearing comparators (<1.2.0-alpha.2, <=2.0.0-rc.1), || groups whose first alternative is an exact version, and the literal *. It touches:
src/install/npm.rs: rewritesfind_best_versionandfind_best_version_with_filter— the exact-version fast path now usesGroup::get_exact_version(), thelatestdist-tag is preferred whenever it satisfies (or unconditionally for literal*), and both the release and prerelease lists are scanned with the higher result winning. Also reworks hownewest_filteredis tracked across the two scans and how the*path interacts withminimumReleaseAge.src/semver/SemverQuery.rs: addsFlags::STARset only when the input is literally*, exposesGroup::is_star_literal(), and folds the flag intoGroup::eqlso*vs>=0.0.0/xare distinguishable for lockfile diffing.test/cli/install/bun-install-version-resolution.test.ts: new 15-case suite with an in-process registry, expectations cross-checked against npm 11 / npm-pick-manifest.
Security risks
None identified. There is no auth, crypto, filesystem, or network surface change here; the registry response handling is unchanged. The change is purely which already-published version gets selected from a manifest. The new test file spins up a local Bun.serve registry on port 0 in the test process, which is the established pattern in sibling install tests.
Level of scrutiny
High. find_best_version / find_best_version_with_filter run on every npm dependency in every bun install, and a wrong pick silently locks a different version than npm would — exactly the class of subtle, hard-to-bisect bug this PR is fixing. Over the course of review this PR went through four rounds of feedback from me, each finding a real issue (the structural is_star() matching >=0.0.0/x; the AllVersionsTooRecent early-return swallowing the stable fallback under minimumReleaseAge; FoundWithFilter diagnostics being dropped across the two scans; Group::eql ignoring the new STAR flag). All have been addressed with targeted fixes and regression tests, and the current pass found nothing further — but the iteration history itself argues for a maintainer reviewing the final shape rather than auto-approving.
The Group::eql change also deserves a human look: it now distinguishes * from >=0.0.0/x, which is correct for the resolution semantics introduced here but is consumed by lockfile diffing, overrides, and catalog comparison via Dependency::eql, so the blast radius is wider than the two functions in npm.rs.
Other factors
- CI on the most recently reported build is red (robobun reports failures on Build #65471 for commit 808de80); worth confirming whether those are related or pre-existing flakes before merge.
- Test coverage is good: the new suite pins each behavior change against npm-verified expectations, and the PR description states the existing
prereleases-1..4matrix andminimum-release-age.test.tsare unchanged. - Supersedes #30076 (the
||fast-path fix alone), so that PR should be closed if this lands. - All prior automated review comments (mine and CodeRabbit's) are resolved.
|
This came up again in a semver-parity fuzz round against npm 11.16.0 / npm-pick-manifest 10.0.0 ( main...robobun/c58f647d/npm-pick-parity Differences from this PR:
Verification on that branch: a differential run of |
|
Closing as part of a cleanup of stale pull requests. This PR has had no new commits since 2026-06-27, it conflicts with main, and its last CI run failed. This is not a judgment on the fix itself. If the problem still reproduces on a current build, reopen this PR after a rebase or open a new one against main. |
bun installresolves three classes of npm ranges to different versions than npm, and fails an install npm completes. All of them come fromPackageManifest::find_best_version/find_best_version_with_filterinsrc/install/npm.rs.Repro
Against a registry with the listed versions (
latestas shown),bun install --lockfile-onlypicks:<1.2.0-alpha.2<=2.0.0-rc.11.0.0 || ^2.0.0*No version matching "*" found for specifier ... (but package exists)*The fourth one is the worst: a package whose published versions are all prereleases (nightly/canary-only packages) aborts the whole install with
error: No version matching "*" found for specifier "<name>" (but package exists).Cause
group.head.head.range.left.op == Op::Eql, which is true for the first||alternative of1.0.0 || ^2.0.0, so the rest of the group was never evaluated (order dependent:^2.0.0 || 1.0.0resolved to 2.1.0).latestdist-tag was also only honored when it compared equal to the range's left version, instead of npm's "preferlatestwhenever it satisfies".*requiredlatestto satisfy the group, which a prerelease never does without a prerelease comparator, so prerelease-only packages errored. npm treats the literal*as thelatestdist-tag unconditionally.Fix
In both
find_best_versionandfind_best_version_with_filter:Group::get_exact_version()(single exact comparator, no||/&&/right bound)latestdist-tag when it satisfies the range, matching npm-pick-manifest (and pnpm)latestdist-tag unconditionally for the literal*. npm only does this for the literal*(not>=0.0.0orx, which parse to the same structure), so the parser records the literal in a newFlags::STARbit (Group::is_star_literal())minimumReleaseAge, route*through the same dist-tag fallbacklatestuses, so a too recentlatestfalls back to an older version of the same release channel instead of failingVerification
New suite
test/cli/install/bun-install-version-resolution.test.ts(local registry, packuments only): 10 of 13 tests fail on bun before the fix, 13/13 after. Every expectation was produced by running npm 11 against the same packuments, not by assumption (npm is not puremaxSatisfying: it prefers a satisfyinglatest, which the tests also pin).Cross-checked with the same harness that the existing prerelease matrix in
test/cli/install/bun-install-registry.test.ts(prereleases-1 through prereleases-4, 34 expectations) is unchanged, andminimum-release-age.test.ts,bun-install.test.ts,bun-add.test.ts,bun-update.test.tsshow no new failures.Supersedes #30076, which fixes only the
||fast path part of this.npm 11 / npm-pick-manifest / node-semver / bun comparison after the fix
Before the fix, bun disagreed with npm on pre-above-stable (1.1.1), range-pre-upper (1.2.0), vp (1.1.1), or-exact (1.0.0), or-scan (1.0.0), only-pre (install error), star-pre-latest (1.0.0), and pre-range-latest-stable (1.3.0).