Conversation
…kfile package-lock.json, yarn.lock and pnpm-lock.yaml do not carry trustedDependencies, and the migrators never read them from package.json, so the bun.lock written by `bun pm migrate` lacked the field. A later install applied the package.json list in memory, but --frozen-lockfile never writes the lockfile back, so `bun pm untrusted` and `bun pm trust` kept reading the default trusted list instead of the project's. Every migration now records the root's and each workspace member's trustedDependencies the same way Package::parse_with_json does for a fresh install, sharing the parsing code with it. Fixes #38193
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
|
Updated 11:05 PM PT - Aug 14th, 2026
❌ @robobun, your commit 85d575b has some failures in 🧪 To try this PR locally: bunx bun-pr 38773That installs a local version of the PR into your bun-38773 --bun |
|
Status: ready for review. CI build 97010 ran 177/179 jobs green; the remaining two ( Reproduced #38193 against the test registry on the released build: The missing |
|
why does this read trustedDependencies from all workspace package.jsons? isn't it normally the root package.json we read from? also pnpm trusted dependencies are called onlyBuiltDependencies right? |
|
Because that is what Yes, pnpm's equivalent is |
|
Closing in favor of #41908, which carries this change ( #41908 now also uses this PR's shape for it: one post-migration step with the same |
Fixes #38193
Problem
bun pm migratewrites abun.lockwithout the project'strustedDependencies, for all three sources (package-lock.json,yarn.lock,pnpm-lock.yaml). A freshbun installrecords them.migration.rs/npm_lock.rsapply_root_overrides,yarn.rsparse_root_overrides, the importer manifests inpnpm.rs), soLockfile::trusted_dependenciesstaysNonewhenpackage_manager_command.rssaves the migrated lockfile.bun pm migrate+bun install --frozen-lockfile+bun pm untrustedflow): the frozen install applies package.json's list in memory and runs the right scripts, but never writes the lockfile back, sobun pm untrusted/bun pm trust(which read the lockfile,pm_trusted_command.rs) report the default trusted list instead of the project's: the trusted package is listed as blocked and the packages the list blocks are not. A plainbun installfixes the lockfile, a CI install never does.trustedDependencieslist that the lockfile does not record fails--frozen-lockfile), a migrated lockfile would failbun cioutright without this change.Fix
migration.rs: after any successful migration,record_trusted_dependenciesreads the root package.json and every entry oflockfile.workspace_paths(the members each migrator found) through the workspace package.json cache and appends theirtrustedDependenciesto the lockfile. A malformed field fails the migration with the same errorbun installprints for it.Package.rs: the parsing moves out ofparse_with_jsonintoparse_append_trusted_dependencies, used by both, so a migrated lockfile records exactly what a fresh install records: the union of the root's and the members' lists, andSome(empty)when a list is declared, which is what turns the default list off.package-lock.jsonandpnpm-lock.yaml.yarn.lockmigration does not migrate workspace members at all yet (its own test carries the TODO), so there only the root's list is recorded; a lockfile migrated from a yarn workspace fails--frozen-lockfileanyway and the plain install that follows records the members' lists itself. Whatever adds yarn workspace migration fillsworkspace_pathslike the other two and is picked up here unchanged.bun installwas already corrected by the differ afterwards; it now produces the same lockfile directly.test/cli/install/bun-install-lifecycle-scripts.test.ts,trustedDependencies survive lockfile migration(4 tests: root list for each of the three sources, plus a pnpm workspace whose member declares the list). Each runsbun pm migrate, checks the field inbun.lock, installs with--frozen-lockfile, checks thatuses-what-bin's script ran and default-trustedelectron's did not, and checksbun pm untrustedlists onlyelectron. All four fail on the released binary at thebun.lockcheck and pass with this change.test/cli/install/migration/(remaining failures there need network or are the known 5s debug timeouts ofyarn-cli-repo/ the pnpm comprehensive case, which pass when run alone),cargo clippy -p bun_install, the source lints.Background
trustedDependenciesis the package.json allow-list for dependency lifecycle scripts. When no package.json in the project declares it, bun uses its built-in default list; declaring it (in the root or in any workspace member, even empty) replaces the default list for the whole install.Lockfile::trusted_dependenciesisOptionfor that reason, andbun.lockstores the field so later installs andbun pm untrusted/trustsee the same list.bun pm migrate, or automatically whenbun installfinds only a foreign lockfile) builds aLockfilefrom the other package manager's file.detect_and_load_other_lockfiledispatches to the three migrators and is where the shared post-step lives.Diff::generate) compares the loaded lockfile with package.json on every install and applies differences in memory;--frozen-lockfilestill does that but never saves, which is why the bug only shows up through the saved file.