Repository navigation
install: fix regressions and older bugs found after the package manager consolidation - #45307
Conversation
…er consolidation Follow-up to #44968. Fixes the regressions reported after it landed and the older package manager bugs found while checking them: resolution and lockfile stability, hoisted and isolated layout, the global store, patches, migrations, git dependencies, config paths, auto-install, `bun pm diff`, `bun pm version`, `bun publish`, `bun audit` and the security scanner. Also removes several slowdowns: the runtime no longer parses the dependencies of every package it loads from node_modules, two quadratic loops in the resolver and two in the isolated store builder are gone, and a git checkout needs one clone less.
|
Updated 9:05 PM PT - Oct 15th, 2026
❌ @Jarred-Sumner, your commit 5501a18 has 2 failures in
🧪 To try this PR locally: bunx bun-pr 45307That installs a local version of the PR into your bun-45307 --bun |
…ppy fixes The check for a name that appears in more than one dependency group was quadratic in the number of devDependencies in three places. One helper now does it in linear time and returns at once for packages without dev or optional rows. Also fixes three clippy lints and indexes hoisted folders by position in `served_peers`.
…tories Also makes adopt_contained_folders non-generic: it only needed the resolver for one inner parse call, which it now takes as a closure.
The pass that decides which hoisted rows stay now asks once per edge whether it is left out and returns early when nothing is, which is the common case. Paths that are already normalized are joined by a plain copy, and the "has a tree" lookup no longer hashes a tuple per package. `is_unlinked_member` answers false for a tree without a parent instead of indexing with the sentinel, and the row-keeping pass is no longer compiled once per builder method.
A relative specifier with a backslash is split at the backslash by the module resolver on POSIX, so no file of that name can be loaded, scanner or not.
…diff folds, lint fixes - The yarn printer keys a row by the name in package.json only when the row is an `npm:` alias; tarball, git and folder rows use the package's own name again. - A dependency that does not start with `npm:` takes the same path as before when a lockfile is loaded: no extra call, no extra parse. - The slow part of the "name in two groups" check is compiled once, and `adopt_contained_folders` gets the parsed rows back from its callback. - pnpm migration: the patchedDependencies key of a git-hosted package in package.json follows the resolution, which is the key the patch is applied under. - pm diff: a closing bracket that came in with an added block no longer counts as part of the old side, so the file keeps its folds; a display that was not renamed is compared under its own names; directives stay in the comparison text in readable files too (the internal parser option is now called keep_directives); a field that is equal for install is still compared between the two package.json files.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe pull request updates Bun’s package resolution, installation, lockfiles, workspace handling, and package-manager commands. It also changes runtime auto-install, archive extraction, patch processing, diagnostics, public APIs, documentation, and regression tests. ChangesPackage resolution and installation
Priority: ⬆️ High Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
…eak, and CI failures - `bind_update_requests` compared the request's version literal through a buffer that a later append could reallocate. The request now keeps what the user typed as process-lifetime bytes. - The list of foreign flag rewrites is parked in a static instead of leaked. - The hoisted row-keeping pass takes its shortcut only when no place is contested by two dependency groups. - A cafile that does not fit the path buffer is refused before the HTTP thread starts, with the same message as before. - The working directory is read with the call that names a deleted directory, so the hint is printed again. - A connect that fails at once (macOS, closed loopback port) counts as "cannot be reached" for best-effort manifest lookups. - Tests: separators on Windows, one rm per folder.
…tside workspace on Windows, pm diff directives - `bun patch` took every freshly installed folder for one it had handed out when files have a link count of 1 (clonefile, copyfile). A folder laid from another cache entry is now told apart by its tag file, and on macOS a clone by its modification time. - `bun pm ls` resolves the path of a workspace outside the project before it asks whether the folder exists; Windows takes `..` literally behind `\\?\`. - pm diff: a parenthesised string is an expression, not a directive, and a directive is compared as written. When two re-prints are the same text but the programs differ, the files' own lines are shown.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟡
packages/bun-types/bun.d.ts— nit: the bun.lock type is missing the newhasInstallScriptkey. src/install/lockfile/bun.lock.rs:1053-1055 writes"hasInstallScript": trueinto a package's INFO object and the parser at src/install/lockfile/bun.lock.rs:2336-2340 reads it, butBunLockFilePackageInfoonly gainedunresolved. Fix: addhasInstallScript?: truenext tobundled?: truesoBun.BunLockFileconsumers see every key the writer emits.Why this was flagged
The Stringifier in src/install/lockfile/bun.lock.rs:1053 emits
"hasInstallScript": truefor a package whose meta has an install script, and src/install/lockfile/bun.lock.rs:2336 parses it back. A TypeScript program that readsbun.lockthrough theBunLockFiletypes at packages/bun-types/bun.d.ts:10671-10675 gets a type error or ananyescape on that key because the type was not extended; on the base branch the key did not exist, so the types and the file agreed.Verification: nit. Triggering condition: any TypeScript consumer that reads a
bun.lockwritten by this PR through theBun.BunLockFiletypes and touches the new key. The PR adds a writer line in src/install/lockfile/bun.lock.rs:1053-1054 forhasInstallScript;BunLockFilePackageInfoat packages/bun-types/bun.d.ts:10671-10675 has nohasInstallScript, so the public type no longer matches what the writer emits.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Still open from earlier reviews (3):
- 🔴
src/libarchive/lib.rs:331—Callers of Bun.Archive.files() now get silently wrong bytes for a sparse tar member: holes are dropped and chunks are c… - Also unresolved: 2 minor or pre-existing.
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
- A package.json with both "overrides" and "resolutions": only "overrides" is read, as before #44968. An upgrade no longer rewrites bun.lock. - "incorrect peer dependency" warnings are printed only with --verbose. - Bun.Archive.files() returns sparse members whole again. - bun patch always starts from a clean copy, as on main. - Auto-install's wait no longer looks at signals; the scanner check reads bunfig.toml from the working directory up to the project root. - A short read of an installed package.json is read to the end before the package counts as missing. - A cached git checkout whose package.json is a link is checked out again. - A bin link is left over only when it leads into a package this run replaced. - A peer dependency is stored as the package its dependent loads. - yarn.lock and package-lock.json migrations: forks, hosted-git archives, workspace members, bins of tarballs, one bad entry, one bad lockfile. - Leftover nested copies, self-contained workspaces, prune --production, bins written by install scripts, trusted file: folders. - Pins in bun.lock are held against the overrides of package.json. - Leaks in argument parsing, Windows test fixes.
- bun upgrade: borrow the environment for the proxy settings. - The rest of the bunx, manifest cache, network and small fixes.
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
The last 3 reviews of this pull request each found new blocking issues, repeatedly in src/install/lockfile/Tree.rs. Where they share a root cause, one fix may close them together.
…ows build of the tar writer - The step that downloaded tarball dependencies after a yarn or pnpm migration to read their bins is gone, with its tests: it could fetch a cached tarball again. - The tar writer's strategy argument is only read on unix.
There was a problem hiding this comment.
Beyond the inline findings, two more candidates from this push were checked and ruled out: git dependencies being serialized behind the first task (start_git_tasks only holds the others until the Step::Config query settles git_env, and schedule_tasks restarts the loop on the next tick, so the first task's own fetch/checkout does not block them), and auto-install from inside a workspace member without a bun.lock losing sibling workspaces (init_with_runtime promotes project to the root find_workspace_root returns before parse_runtime_root reads it, so the root's workspaces are loaded).
Extended reasoning...
Findings-present ruled-out note only: the two candidates named were traced in src/install/git_runner.rs (start_git_tasks / Step::Config exit handler) and src/install/PackageManager.rs (project resolution ahead of parse_runtime_root) and do not reproduce as described. The two confirmed inline findings (bunx-triggered nested install in runTasks.rs and missing bins for migrated tarball rows) remain for the author.
The last 4 reviews of this pull request each found new blocking issues, repeatedly in src/install/lockfile/Tree.rs. Where they share a root cause, one fix may close them together.
Still open from earlier reviews (2):
- 🔴
src/install/PackageInstaller.rs:1950—Every install command now re-copies each trusted file: dependency and re-runs its install scripts, even when nothing ch… - Also unresolved: 1 minor or pre-existing.
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟣
src/install/PackageManager/processDependencyList.rs— Users migrating from yarn.lock or pnpm-lock.yaml get no node_modules/.bin links for tarball dependencies with bins, and bun.lock records no bin, so every later install stays without them. A migrated tarball row (URL, file:, or a GitHub archive such asg@ o/r) is bound from the lockfile withbin: Bin::init(), is only extracted by the install phase, andappend_extracted_packagereturns the bin-less row at processDependencyList.rs:151-153. Fix: record the bin of a migrated tarball row from the extracted package.json (at install-time extraction, or by re-resolving rows migrated without bins) without downloading a cached tarball twice, and restore the deleted tests. Pre-existing for yarn url/file tarballs and pnpmhasBinrows; the yarnowner/repoarchive form is new in this PR. [also at: test/cli/install/migration/yarn-lock-migration.test.ts:3674 - nit, pre-existing: users migrating from yarn.lock or pnpm-lock.yaml still get no.binlinks for a tarball or hosted-archive dependency that declares bins, and bun.lock then records that package withoutbin, so the links never appear on later installs.]Why this was flagged
A project with yarn.lock (or pnpm-lock.yaml) whose dependency is a tarball with a
binrunsbun install. migrate_yarn_lockfile (src/install/yarn.rs) creates a RemoteTarball package withbin: Bin::init()and binds the root row to it. The package is loaded, so it is never resolved again: the tarball is extracted in the install phase throughon_extract_package_installer(src/install/PackageManager/runTasks.rs:1302-1314), which does not parse package.json into the lockfile, andappend_extracted_packagereturns the existing row at src/install/PackageManager/processDependencyList.rs:151-153 unless the integrity moved. The hoisted installer links bins from the lockfile column (src/install/PackageInstaller.rs:1501packages.items_bin()), sonode_modules/.bin/gis not created and the saved bun.lock has no bin for the row, so later installs do not create it either. On the base branch the same holds for yarn url/file tarballs and pnpm rows (pre-existing); for yarnowner/repoentries the base resolved them as a registry package instead, so the bin-less install of the right archive is new here.Verification: Pre-existing, as the base fails the same way by the same route. src/install/yarn.rs:776 appends migrated tarball rows with
bin: Bin::init(), processDependencyList.rs:151-153 returns the bin-lessexistingrow, and src/install/PackageInstaller.rs:1528-1537 only back-fillsintegrity, neverbin, so no.binentry is created and bun.lock is saved with no bin.
… fixes - A trusted file: folder is not laid and built again by every install. - bun.lock keeps the root's name as it is; a rename is not a lockfile change. - bun run and bunx keep the folder of package.json on PATH in sub-folders. - link_free_bins takes a slice. - package-lock.json: a shorter warning for an entry without an integrity. - Tests: yarn-stuff snapshot, separators on Windows, a helper's name.
- A cached clone is used only as bun left it; anything else is cloned again. The URL is on git's command line and hooks are off. - The variables bunx sets for the install it spawns name its own folder, are checked against it, and do not reach scripts or git. - A peer's stored package moves only to a copy in range that the project or the package itself provides. The isolated store and bun.lock are as before. - The check of bun.lock against overrides skips what earlier versions write honestly: peers that share a version, a name in two groups, optional rows, prerelease pins. - An override added later reaches a package that only a peer holds. - The "patch no longer applies" warning covers tarball and git dependencies.
…_dir_z, which lost its last caller
There was a problem hiding this comment.
Beyond the inline findings, I re-checked the bunx env scoping from the latest push: BUN_INTERNAL_BUNX_INSTALL now carries the bunx cache dir, is_bunx_tree in src/install/PackageManager/runTasks.rs compares it (after realpath) with the root package.json dir, and the variable is dropped from the map that lifecycle scripts, the scanner and git inherit (src/install/PackageManager.rs:2435, src/install/repository.rs:47) — so a nested bun install in another directory is no longer treated as the bunx tree.
Extended reasoning...
The latest commits change the bunx marker from "true" to the cache dir path and add a path comparison plus env removal before scripts spawn; this closes the nested-install concern raised earlier, and the two candidate issues at src/runtime/cli/bunx_command.rs:1024 were ruled out for that reason. Four new inline findings (git_runner offline cache reuse, pack bundledDependencies climbing and in-place rename, pm version preid) remain for the author.
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 4 findings from earlier reviews are still open above.
Still open from earlier reviews (4):
- 🔴
src/install/git_runner.rs:797—Users running bun install --offline with git dependencies cached by an older bun now get "--offline: git repository for… - 🔴
src/runtime/cli/pack_command.rs:656—Users of bun pack/bun publish with bundledDependencies can get a package from outside the project (an ancestor's node_m… - 🔴
src/runtime/cli/pack_command.rs:2198—Users who pack to a destination file they can write but cannot replace now get a crash where the base branch wrote the… - Also unresolved: 1 minor or pre-existing.
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
…rest Taken out, main's behaviour is back: - Two versions of a name that is listed in two dependency groups, with the lockfile entries for them. - The removal of nested copies that goes by the disk alone. An install removes a folder only if the bun.lock it started from placed a package there. - "An override does not displace the link to a member of that name": a bun.lock written by 1.4 passes unchanged again. - The re-read of directories after a failed require.resolve with paths. - An empty trustedDependencies list in bun.lock. - bun patch going on without a patch file that is missing. - Three rules of the tar reader that refused archives main installs; Bun.Archive.files() reads entries with main's code. Fixed: - Nothing behind a node_modules that is a symlink is cleared, root or workspace, either linker. - bun patch --commit changes nothing until every check has passed. - bun pm pack: the destination changes only once the tarball is whole; its temp file is never packed; bundled dependencies are looked up inside the project; a workspace also goes by the ignore files of the workspace root. - Cached git clones: the config is bun's own before every use, so clones of older versions keep working, offline too; odd link names, chains of links, links through folders, damaged clones, #HEAD. - bun.lock loads back as it was resolved for a workspace next to the published package of its name. - Symlinked and outside workspaces: bun add inside one, its bin, speed. - Auto-install: a package.json that only marks the module type is no project. - bunx -p pkg cmd runs any command; npm's --save-* flags on remove and update. - bun pm cache rm, one-shot registry requests, long names, ~/ in variables.
What does this PR do?
Follow-up to #44968. It fixes the regressions that showed up after that PR landed, plus older package manager bugs found while checking them, and makes
bun.lockindependent of network timing. Almost every fix comes with a test that fails onmain. Some earlier changes caused regressions of their own and were taken out again; see "Known to be still open".Fixes #24190
Fixes #20015
Fixes #45070
Fixes #29944
Behavior changes to sign off
One line each. Details are in the groups below. "Reversible" means the change can be backed out on its own, in the place named.
mainuses. Not a small revert.node_modulesthat is a symlink (the project's or a workspace's), remove nothing behind it in their cleanup passes, and warn;bun prunestops with an error. Hoisted followed such links before install: consolidate the open package manager pull requests #44968; isolated replaced the project's with a real folder (npm replaces, pnpm follows). Not a small revert..binnamed like a package's command stays, and the install fails withEEXIST. Reversible:is_behind_linkinbin.rs.move_or_deleteinisolated_install.rs.bun.lockonly, not on--production/--omit/--filter/--os/--cpu. Older versions worked the places out anew for such a run, so an install that lays something over an existing tree also removes the folders at places only the older layout fills. With those flags that costs one more hoist (about 5 % of such a run); fresh, warm and nearly all plain installs pay nothing. Not a small revert.bun.lockgets three optional additions with nolockfileVersionbump:"unresolved","hasInstallScript"and"./<name>/<dep>"entries. Reversible: one writer and one parser block each inbun.lock.rs.bun.lockagainst theoverridesthat name a version or a range: a locked version that a rule forbids is resolved again, and--frozen-lockfilefails. 29 lockfile shapes written fresh by 1.4 pass unchanged; a 1.4 lockfile that disobeys its rules (half a merge, a migration, a rule added later) is rewritten. Reversible:rows_outside_overrides.overridesfor the name of a workspace apply to dependencies of the root and of other workspaces again, as in 1.4, whosebun.lockfailed--frozen-lockfileand was rewritten. This undoes install: don't let overrides displace workspace member links #37271, which came with install: consolidate the open package manager pull requests #44968.bun add <pkg>,bun install <pkg>andbun update <pkg>send every package when there is no lockfile, only another package manager's, or nonode_modulesfolder, otherwise what the command adds or moves. Reversible:|| !loaded_lockfileand|| !has_node_modulesinsecurity_scanner.rs, and thenarrowline in the runner.bunfig.tomlor.npmrcfails closed: commands that install or publish stop (a directory there only warns). npm ignores an unreadable.npmrc, so a root-owned~/.npmrcfromsudo npm loginnow blocks them. Reversible: the two calls ofrefuse_unreadable_config.XDG_CONFIG_HOMEthat is empty or not absolute is ignored, and$HOMEis used. Before,~/.bunfig.tomlwasn't read at all then..npmrcand bunfig's[install]in every folder from the project root down to the importing file (the nearer wins). It turns itself off when one of them, or apackage.jsonon the way up to the workspace root, can't be read or parsed; a broken~/package.jsondoes that for everything below it. In a monorepo without a lockfile it reads every workspace'spackage.jsononce.../x, an absolute path, a link that leaves the root's folder) is linked to and stays inbun.lock, but its dependencies aren't installed and its scripts not run, as in npm; anote:says so. Its ownbinis still made executable. Commands that install, typed in one that is a link, end with an error and change nothing; onmainthey installed there. This affects layouts like Workspace packages with symlinks are not discovered duringbun install#25801 under the isolated linker, and Explicit workspace members under symlinked directories install, then fail at runtime with broken package-local node_modules links #29598 asks for the opposite; both stay open. Reversible:Lockfile::is_member_outsidereturns false.npm:alias in a dependency's manifest applies to that dependency only; the project's own aliases are still followed everywhere.git restoreis from 2.23;--end-of-options, whichmainalready passes for a#ref, from 2.24).submodule.recurseand replace objects off, and a cached clone'sconfigis rewritten with Bun's own text before each use.gitlab:,bitbucket:,gist:andsourcehut:dependencies are written tobun.lockand printed asgit+ssh://git@gitlab.com/user/repo#<sha>(npm's form); they failed to install frombun.lockon a clean machine. Old entries still install and aren't rewritten by a plain install.file:.,workspace:*on the root) is a live link to the project folder, not a hard-linked copy of the repository; the old copy is removed on the next install.patches/libarchive/tar-npm-compat.patch: a reader optionnpmthat only package tarballs set. Every other tar reader,Bun.Archiveincluded, reads as before. Reversible: remove it fromscripts/build/deps/libarchive.tsand drop the option.bun pm cache rmfrees the old ones. Reversible: dropGLOBAL_STORE_LAYOUTfrom the entry hash.PATHentries of the formX/node_modules/.binby their real paths, so a dependency's script no longer finds the project's shared.binahead of the systemPATHthrough a link. Reversible:resolve_bin_dirs_in_path.--exact/exact = truealso pins a typed range, also with--catalogand for an alias:bun add -E react@18writes18.3.1, not18, as npm does. Reversible: one condition inPackageJSONEditor::edit.bun add pkg@2.0.0without a group flag rewrites every entry of a name that is listed in several dependency groups, unless the install leaves one of those groups out (--omit,--production). It wrote an entry that no install reads, so nothing changed.package-lock.jsonentry from another host without anintegritykeeps its version and takes its tarball and integrity from the configured registry, with a warning; the whole lockfile used to be ignored. One older test pinned that.bun pm cache rmempties the cache directory and keeps it, so one that is a symlink, a mount point or in a read-only parent goes on working (5 expectations changed).bun pm cache rm <word>, which cleared everything, and unknownbun pm cachesub-commands are errors.bun info,bun pm view,whoami,diffandbun auditretry a failed request likebun install; one 503 or dropped connection used to end them. With the registry unreachable they fail after about 8 s, not at once; a timeout or a 501 isn't retried.bun publishstill uploads once.bunx's daily refresh costs one manifest request per package.bunxinstalls into the cache directory that~/.bunfig.tomlor~/.npmrcnames (macOS, Linux); it ignored both.bun publishrefuses a prerelease version without--tagorpublishConfig.tag, like npm 11 (reversible: the secondifinrefuse_tag), and a tag that is a version or a range.bun publishreadspublishConfigagain afterprepublishOnly,prepackandprepare, like the name and version (flags still win). Of two equal keys inpackage.jsonthe last one counts, as inJSON.parse. A symlink at the name Bun gives the tarball is replaced, not written through.bun auditfails on an empty answer (empty body, 204, 304). One test from install: consolidate the open package manager pull requests #44968 pinned the old result.patchedDependencieskey of a git-hosted package is rewritten inpackage.jsonto Bun's own key (name@github:owner/repo#<sha>); with the old key the next install dropped the patch silently. One expectation of two older tests changed.bun pm versionfollows node-semver'sinc. Four existing tests pinned other values.bun pm diffprintsdiff --gitfor files whose contents are in the patch (reversible:patch_nameinpm_diff_command.rs).--jsonhas two new keys for binary files,sha256Beforeandsha256After.warn: incorrect peer dependency ...is printed only with--verbose.node_modules/.bunin place of a package is replaced by every install;mainkept it.package-lock.jsonthat can't be used,bun ci,--frozen-lockfileandbun pm migratewarn and try ayarn.lock; they failed..binstays while the package it leads into is there: its build makes the file.Output::err, the path in a system error, the$ scriptline ofbun runand the log printer's source excerpt (bundler,bun lint,bun fmt,bun check) spell out control and bidirectional characters, and a path or line that isn't UTF-8 prints U+FFFD. In an excerpt a NUL stays. Reversible: one place each infmt.rs,output.rs,sys/lib.rs,ast/lib.rs.yields_to_other_requests.Bun.whichno longer takes a file without the execute bit for a command. Reversible: one#ifinc-bindings.cpp.Regressions from #44968
Resolution and lockfile:
package.jsonwith bothoverridesandresolutions: install: consolidate the open package manager pull requests #44968 applied both, so the firstbun installafter the upgrade rewrotebun.lockand could move versions. As in every earlier release,resolutionsis read only when there is nooverrides, and abun.lockwritten by 1.4 installs unchanged, frozen or not.bun installrejected its own freshbun.lockwithdependency cycle cannot be laid out in node_moduleswhen an optional dependency has no published version that fits, or when a cycle is closed only through an optional peer.bun installadded a nested copy, and abun.lockentry for it: of a package whose name an unresolvable optional dependency has, and of an unmet peer whose dependent is installed in two places.bun.lockcould fail--frozen-lockfileright away, or change on the next install with nothing edited: with optional peers, and with a workspace and the published package of its name both installed and a peer dependency on that name.bun.lockb: after a peer moved to another version, the old one stayed in the file with nothing depending on it.--frozen-lockfilefailed, andbun audit,bun whyandbun pm hashsaw it. (A peer that ends at a copy outside its range still leaves one.)--frozen-lockfileandbun cireported an out-of-date lockfile when a workspace has a peer dependency on another workspace's name but gets it from its own dependency on the published version.bun updatewas held back by the peer range of a package that loads another copy.packageExtensions: a freshbun.lockfailed its own--frozen-lockfilewhen a rule matched a version the lockfile doesn't list. Removing a rule that had added two or more dependencies could crash this and every later install, and what it had added stayed loadable.bun add <name>at the root of a monorepo that has a workspace of that name wrote the registry's latest version but installed the workspace. It writesworkspace:*again. A root dependency on a dist-tag of such a name links the workspace from the first install.package.jsonhas a free-textname("Project: X","foo@1") failed to install. It installs under the fallback name a nameless package gets, andbun.lockloads afterwards.file:folder inside itself was installed without that folder's dependencies. A folder that isn't in the package is now an error.workspace:,link:,catalog:and tarball-path entries of such a folder are left out: they mean something in the author's project only.touch package.json && bun installexits 0 again. An emptypackage.jsonnext to a lockfile is still an error.>=0.0.0-a *stopped matching prereleases of0.0.0. A comparator that means>=0.0.0admits them, as in npm.Git dependencies:
bun installcould rungit fetch --pruneon your project's own repository, and delete local branches and tags, when the cached copy of a git dependency was no longer a repository and the cache sits inside the project's work tree. Every git call now names its repository with--git-dir.cannot lock refwhen a git dependency had new commits (9 of 20 runs). Such a fetch runs once more.#reffailed on every warm cache. A cached repository follows the remote's current default branch, also for#HEAD.Linkers:
node_modulesa symlink, an isolated install deleted everything in the folder behind the link. Hoisted did the same when that folder holds a.bunfolder, deleted a folder there named like a dependency that had leftpackage.json, and replaced a workspace's linkednode_modules(on a volume, a cache disk) with a real directory.bun removeorbun installthat failed to savebun.lockorpackage.jsonstill deleted packages.bun add,bun installandbun removedeleted the copy of a dependency that a package's new version bundles, or ships undeclared in itsnode_modules.rm -rf node_modulesat the root) deleted.cache,.viteand other tools' dot entries in everynode_modules. They stay. What belongs to a package manager (.pnpm*,.modules.yaml,.package-lock.json,.yarn-integrity,.yarn-state.yml) goes with the old tree.PATH_MAXcrashed on the new staging directory, andbun pm untrusted/bun pm trustdidn't seelink:dependencies.scriptsbut nohasInstallScript. Bun derives it fromscripts, as npm does. That also fixes the older gap underminimumReleaseAge.Speed:
bun whyno longer slow down with the square of the number of direct dependencies (an old cost).bun file.jsparsed everydependenciesentry of each package it loaded fromnode_modules(up to 2x the instructions and +50 MB with 2,000 packages, about +7 % on a realistic tree). A range is parsed only when auto-install asks for that name.Commands:
bun install,ci,add,removeandupdateaccept the common npm, Yarn and pnpm flags again.--save-dev,--save-exact,--no-optional,--only=production,--immutable,--loglevel=...and others map to Bun's flags (bun remove --save-devdrops the flag).--no-audit,--no-fund,--legacy-peer-depsand a few more are ignored. Other unknown flags stay errors.bun pm packheld the whole tarball in memory (734 MB and 52 s for a 400 MB tarball). It streams to a temporary file, and the destination changes only once the tarball is whole: a failed pack keeps an earlier tarball.bun publishrefused a publish that turns provenance off (--no-provenance,NPM_CONFIG_PROVENANCE=0,publishConfig.provenance: null). Like npm, the command line beatspublishConfig, then the environment, then.npmrc.bun publish -rcrashed or published the wrongworkspace:version for a package that follows one with aprepack,prepareorprepublishOnlyscript. With npm's web login, Enter could open an earlier package's login page.bun pm pkg set --json x=010stored 8. Values that aren't JSON (010,0x10,1_000,.5,'text') are rejected, also inside arrays and objects.bun update --latestwith a name in two dependency lists rewrote one entry whilebun installused the other.bun update --latest <name>rewrites the entry thatbun installuses; the other stays as written.bun update --interactivecrashed in monorepos whose packages writecatalog:default(orcatalog:overcatalogs.default). It updates the catalog entry where it's defined.bun createinto an existing folder replaced your.gitignorewith the template'sgitignorefile. Yours stays unless you pass--force; a template's own.gitignoreis a listed conflict.bun installstill asked the registry for the peer dependencies, with a second round of retries. It stops there. A 404 or "no matching version" below the first level still asks for the peers.bunx tool@latestbroke the copy thatbunx toolruns, andbunx toolwaited for a runningbunx tool@latest. A failure before linking leaves the tree as it was.bun info pkgfailed on a registry document without alatesttag.bun info pkg@*names the versionbun addinstalls.yarn.lockorpnpm-lock.yamlwaited about 8 s when the registry couldn't be reached. It asks once, and uses cached manifests of any age.package.jsonwrites ranges asnpm:^1.0.0lost the versionsyarn.lockpins.bun installreadsnpm:<range>as a range of the dependency's own name when it has a range character or is a complete version;npm:bar,npm:latest,npm:1andnpm:xstay aliases.bun installon ayarn.lockwith a git dependency outside GitHub failed withinvalid git commit "", and--frozen-lockfilestraight on ayarn.lockfailed when the root has a required peer that it doesn't list.bunfig.tomlprinted up to three times. It prints once, and--silenthides it.bun a.jswithout a bunfig does one failedopeninstead of three.import "foo@^2") was overridden by the range inpackage.json.bun patch --commitandbun installrejected patches that delete the last lines of a file with no trailing newline.bun patchand--commitfailed when the project's path contains", a tab or a backslash. A failed--commitwith the global store deleted the edited folder.bun patch --commitno longer removed the patch. It removes thepatchedDependenciesentry, reinstalls the unpatched package and deletes the patch file if it's a regular file inside the project and no other entry names it.Resolution and lockfile
bun.lockkeys:"unresolved": [...], next tooptionalPeers: optional dependencies that couldn't be resolved, listed only when another package of that name is in the tree."hasInstallScript": truein a package's info object (npm's key). Both are inbun.d.ts."./<name>/<dep>"entries: the dependencies of a workspace whose name the root gives to another package.--frozen-lockfile(2 of 900 dense random projects didn't) and drop the additions on their next save, so a team on mixed versions sees them come and go. A plain install doesn't rewrite a lockfile just to add the first two.bun.lockdoesn't list, and a committed lockfile that frozen kept rejecting passes.bun update,outdated,prune,pm licenses,audit,add --trust, the security scanner, the install summary and--production/--omit/--filter. They went by the highest version that fits. Other providers are as before.bun addorbun updatein another workspace could put a newer copy in front of it, outside that entry's range.bun installcould write abun.lockit couldn't read back (Failed to resolve prod dependency,InvalidLockfile) when a package bundles a package that another one names as an optional peer (in 1.4.3 too). Such a peer, if nothing provides it, is no longer installed at the top ofnode_modules.bun installwrites the samebun.lockwhichever response arrives first, with a cold or a warm cache. Each dependency used to be resolved when its manifest arrived, so network timing decided whether a range shared a version.patchedDependenciesresolves to that version.overridescheck under frozen printsnote: bun.lock has b@1.2.9, and overrides in package.json asks for 1.2.0. It leaves alone bundled dependencies, optional peers, and a peer or optional dependency that shares its version with a dependency the rule doesn't apply to.bun add fooandbun update --latestinstalled a version that a version-scoped override ("foo@>=2.0.0": "1.2.0") forbids. They write^2.0.0and install1.2.0, like a clean install.catalog:whose package isn't in the catalog gets a warning that points at the rule.bun installandBun.semverread build metadata after a bare major (2+1,^2+x) as part of that version, not as a second range that let another major through.Bun.semver.order("2+1", ...)no longer throws.Hoisted linker
package.jsonleaves itsnode_modules..binwhen another dependency leavespackage.json(install: consolidate the open package manager pull requests #44968).--production,--omit=<type>,--filter,--osand--cpuused to re-hoist, so a package could move between runs and an old nested copy could shadow the right version. They now skip packages but never move the rest. (--frozen-lock doesn't work with --filter on Bun rust version #45070, --frozen-lock doesn't work with --filter #29944) Such a tree nests the way thebun.lockkeys do: +0 % to +1.8 % folders on real lockfiles.node_modulesonly if thebun.lockit started from placed a package there, or Bun up to 1.4 would have for the same lockfile and flags. A nested copy from before the upgrade used to stay and go on being loaded after the next version bump. A folder that a package ships in its tarball (the cache says; without the cache entry the folder stays), that a script can have laid or that somebody put there stays. What a flag merely leaves out stays too;bun pruneremoves that.package.jsonwith 3 system calls instead of 4.node_moduleswas deleted, a package that changed version was linked over the old folder in a workspace's ownnode_modules, so files of the old version stayed (in 1.4.3 too). Such a folder is treated as in a warm install.bun prune --productiondeleted nested packages below a package that a full install had hoisted to a different folder than a production install would.package.jsonremoved nothing fromnode_modules.bun prunesees it.prepare) is linked by the samebun install, before the root's scripts run.file:folder dependency were dropped silently. Relative links that stay inside the folder are kept, links to files elsewhere in the project (by real paths) are installed as files, and anything else is skipped with a warning.package.jsonornode_modules/.binpath doesn't fit inPATH_MAXfails its lifecycle scripts withENAMETOOLONGinstead of crashing.Isolated linker and global store
package.jsonstayed linked innode_modules, with its.binentries. It's unlinked, also when another package still needs it, inside a workspace (bun remove doesn't remove the package from node_modules when using isolated linker #26305), and in the hiddennode_modules/.bun/node_modules. Only that package's ownnode_modulesis touched, and only a link that leads where Bun had linked it: your own links,bun linkand other workspaces' links stay.node_modulesno longer dangle either.hoistPatternadded to an installed project takes effect on the nextbun install: fallback links it doesn't match are removed. (publicHoistPatternstill only grows.)bun prune --production, a command or a fallback link that a removed package held goes to the package that stays, as in a freshbun install --production.globalStore = true: the first install against a warm store printed nothing useful. It lists what it linked and which postinstall scripts were blocked.globalStore = true: a no-op install deleted and re-created everynode_modules/.bun/<pkg>link (4 system calls per package, now 1). Two installs at once no longer fail withEEXIST, and a running program no longer loses a package for a moment.bun install --forcereplaces a global store entry in one step on macOS and Linux, so other projects never see it missing.BUN_INSTALL_GLOBAL_STORE=false(alsono,offand an empty value) turned the store on.Workspaces
bun.lockentry and gets its own dependencies installed, while the root'snode_modules/<name>holds what the root asked for.bun.lockorbun.lockbfrom Bun 1.4 or older that leaves such a workspace out still passes--frozen-lockfileand isn't rewritten bybun install. The workspace gets its entry the next time the dependencies change, or with a fresh lockfile.bun link <package>inside a workspace treated the workspace as its own project. It installs from the workspace root likebun add: siblingworkspace:andcatalog:dependencies resolve, and--saveupdates the workspace'spackage.jsonand the root'sbun.lock(bun link <package>within workspace that depends on sibling workspace errors #24190, bun link does not work with catalog #20015).bun add <name>inside a workspace, where<name>is a workspace that is also published, links the workspace and writesworkspace:*.bun add <name>@<tag>andbun update --latestfor such a name left a workspace entry bound to the registry package. They install and lock what a clean install of the written range gives.bun add alias@npm:<workspace>wrote"alias": "workspace:*", which every later install rejected. It keeps thenpm:form.bun add lib@npm:otherat the root, with a workspace namedlib, installsotherrather than linking the workspace.workspace:../lib,workspace:lib@^andworkspace:lib@~rejected a workspace with a prerelease version or no version.workspace:range on the root package that the root's version doesn't satisfy is an error, as for any other workspace.Lifecycle scripts and trust
link:dependency runs its lifecycle scripts when it's linked, as with the hoisted linker. An untrusted one is reported as blocked.link:folder without apackage.jsonno longer fails an install frombun.lock.bun.lockreports blocked scripts, because the lockfile records which packages have install scripts.bun pm trustrefuses to run with a frozen lockfile.sharpruns its install scripts like any other package."ignoreScripts": []inpackage.jsonturns the built-in skip list off.bun pm pack,bun publishandbun pm versionrun their lifecycle scripts with the package's and its parents'node_modules/.bininPATH, so"prepack": "tsc"works. Withbun publish -reach package gets its own.preversion,versionandpostversionscripts get$npm_old_version,$npm_new_version,$npm_command,$npm_package_json,$npm_package_nameand$npm_package_version. The new version is computed beforepreversionruns, as in npm, so an invalid or unchanged version fails first.bun create <template>has--ignore-scripts, and skips the template's preinstall and postinstall tasks withignoreScripts = true,ignore-scripts=truein.npmrc(both read in the folder the command is typed in and in the home folder) orNPM_CONFIG_IGNORE_SCRIPTS.bun patchbun patchand--commitfetch the package again when it's installed but no longer in the cache (afterbun pm cache rm) instead of failing withENOENT, also for patched packages and git, GitHub and tarball dependencies.bun patch --commitchanges nothing until every check has passed. If the new patch doesn't apply to a scratch copy, or the install it runs is refused (the security scanner,--frozen-lockfile, a dependency that doesn't resolve), the folder,package.json,bun.lockand an older patch file stay as they were. With the global store,--commit --lockfile-onlydeleted the edited folder.bun add/bun updatewrite nothing..gitattributes,.git/info/attributesor.git/configcould change or empty the patch. git runs without a repository.--commitfailed when a patched file, the project folder or the cache folder has a non-ASCII name, when git only printed a warning (more than 1,000 files deleted and 1,000 added), and for a git dependency whose repository contains symlinks. It reported "No changes detected" when git was killed.patchedDependenciesis missing,bun installandbun patchfail and leavenode_modulesalone. The error namesbun patch --commit <pkg>, which writes the file again from the patched package innode_modules, and says how to drop the entry.--commiton a package that wasn't edited and has trusted install scripts puts it back as installed and runs those scripts again.bun patchlost nested packages and could leave a half-deleted folder. Nothing is deleted before the copy is in place, and an error puts everything back.--patches-dir=/absinside the project is written relative to it.bun patchaccepts an entry of the list exactly as it prints it." b"were deleted, created or chmod-ed at the wrong path.bun patchdropped folders namedCMakeFilesor.gitfrom the copy.bun patchand--commitwhen files are copied rather than hard-linked.bun pruneno longer deletes the folder thatbun patchprepared for a transitive dependency.Tarballs,
bun pm packandbun publish.tarpackages, and.tgzfiles served withContent-Encoding: gzip, failed in the streaming extractor.github:tarball whose first entry isn't its root folder was accepted or rejected depending on whether the response had aContent-Length.Bun.Archive:extract(dir, { glob })andfiles()resolved with the entries read so far on a truncated or corrupted archive. They reject, likeextract(dir).bun pm packandbun publishleftbundledDependenciesout with the isolated linker, in workspaces and for linked folders. They bundle them and everything they depend on from any layout, looking no further up than the project. Sibling workspaces are packed by their ownfilesand.npmignore, and a broken sibling that nothing needs doesn't fail the pack.dependenciesthat isn't installed is an error, no longer left out. So is a ring of bundled versions that nonode_modulescan hold.catalog:dependency whose catalog entry isworkspace:^(or anotherworkspace:form) was published as written. It's replaced with the workspace's version. An entry that is itself acatalog:reference fails the pack.bun pm packleft lockfile-named files out of a dependency of a bundled package whose name containsnode_modules.bun publish x.tgzlooksbinanddirectories.binup in the tarball, not in the current folder.npm-noticeheader is printed for every request ofbun publish.bun publishof2.0.0-beta.1without a tag made itlatest, the versionbun addinstalls. The refusal names--tag nextand--tag latest, and--dry-runrefuses too.bun add ./<path>.tgzwith a path longer thanPATH_MAXfails withENAMETOOLONGinstead of crashing.Git dependencies
git ls-tree, thengit restore --source=<sha> --worktreewithcore.symlinks=false). The second clone and its.gitfolder are gone: about 20 % to 35 % less CPU per checkout on two repositories. An older git gets a note that 2.24 is needed.core.sshCommandfrom any config file, plain includes,GIT_CONFIG_*,GIT_SSH,GIT_SSH_COMMANDandcore.askPassall count. A value behind a conditionalincludeIfis still overruled.git@host:user/repo.gitinstalled frombun.locktried a malformed https URL. It tries the same URLs as a first install.--offline.submodule.recurse = truebroke a git dependency that has a submodule.preparescript of a git dependency fails, a note says that Bun doesn't install itsdevDependenciesfirst.Migrations (npm, yarn, pnpm)
yarn.lockorpnpm-lock.yamlthat pins a GitHub dependency failed on the first install and lost the pin on the second. It installs the pinned commit and writes abun.lockthat loads. Migrated pnpm rows keep the full 40-character commit.pnpm-lock.yamlwith atype: gitresolution installs the pinned commit, whichever wayrepo:is written.patchedDependenciesentry for each version it patches.link:and bare path (./dir) entries failed with "failed to resolve". They're migrated, with theirbin, also for workspaces and with--frozen-lockfile.owner/repoentry is the archive thatyarn.locknames.yarn.lockentry can't be used is resolved instead of failing the install. A dependency of a dependency without a usable entry still fails.bin,osandcpufrom the registry's metadata only when it's that registry's tarball: the same URL, the same hash, or, when the hashes can't be compared, a URL with the registry's layout for that name and version (a mirror).yarn.lockorpnpm-lock.yamlnext to it. Bun warns (...; trying yarn.lock) and tries the next one.bun.lockbincluded) writes them asoptionalPeersany more, so--frozen-lockfileaccepts thebun.lockthatbun installwrites.bun pm migrateleaves such a peer out; the nextbun installadds it.bun install --yarnwrote an npm alias under the package's own name. It uses the namepackage.jsongives it, as yarn v1 does, so an alias migrates back to the same package.Auto-install
bun.lockwas never read withoutnode_modules(onlybun.lockbwas). Bun uses the versions pinned in either, and downloads them on first import.import "foo"also honorsdevDependenciesandpeerDependencies, and walks up to the firstpackage.jsonthat lists the name.overrides,resolutions,catalogsandpackageExtensionsof the project'spackage.jsonapply. An override counts when it names a version, range, tag,npm:alias orcatalog:; one that names a folder, tarball or git repository is passed over, as before.workspace:,file:andlink:dependencies load from their folder on disk, and tarball dependencies load through the cache.package.jsonlists if nothing has loaded that name before. Optional peers are installed when imported.bun --install=forcerejected an import that names a version in a project with apackage.json.HOME) ended the process insiderequire()/import(). The import throws "Cannot find package" with the reason as a note, and packages already in the cache still load.bundledDependenciescan load its other dependencies, and Bun no longer downloads the bundled ones.bunxand global installsbunx <tool>with a day-old copy failed when the registry answered 5xx, 429 or 408, or when the tarball of a newer version couldn't be fetched. It runs the copy it has, and asks a failing manifest once instead of retrying for 8 s.pkg@<range>or any dependency, because the tree's own lockfile pinned them. It takes what was published since, and atool@latestrun no longer puts it off.bunx pkg@3failed in a project that has another major ofpkginstalled. With a version, tag, URL or alias, nothing from the project is used.bunx @scope/pkgandbunx -p pkg cmdfind the bin through that package's ownpackage.json, in the project (no further up than its root) or inbunx's tree, and run that package's file, not another package's.binentry of that name (on Windows the shim is taken as is).bunx -p pkg cmdinstallspkgand runs any command, as npx does, withpkg's commands first inPATH.bunxno longer finds helper commands from an older copy thatbunxhad installed.bunx --no-install pkg@latestruns the copy that is on disk.bunx pkgwithout a version passes over a deprecatedlatest, asbun adddoes.node_modules/.bin/<name>that exists but can't be executed iserror: <path> is not executable, exit 126, instead of a download.bun installthat a package's script starts duringbunxis an ordinary install of its own project.bun add -g/bun update -g: when one bin can't be linked because another file has its name, the command still fails, but the package is saved, sobun pm ls -glists it andbun remove -gremoves it.bun remove -g secondtook a bin name away fromfirstfor good ifsecondhad claimed it. A global package whose bin link is missing gets it back on the nextbun add -g,update -gorremove -g. Nothing already in the global bin folder is replaced.bun update,bun outdated,bun audit,bun pm *bun update --interactiverewrote every range as "first character + chosen version". Ranges such as>=1.0.0 <2,1.x,*,^1 || ^2orlateststay as written when they already allow the chosen version.bun updatewith--exactorinstall.exactno longer pins apeerDependenciesrange, or a catalog entry that acatalog:peer uses.bun update --latestwithout names leaves a peer range in apackage.jsonthat already allows the latest version (one in a catalog is still rewritten).bun outdatedhid dependencies that are ahead of thelatesttag (next/canarychannels,latestkept on an LTS major). It lists them whenbun updatewould move them. It also printed an optional peer twice.bun update --latestandbun update -idowngraded a dependency that is ahead oflatest, including one written as a dist-tag such as"canary". No key or flag in-ican pick an olderlatest, and it no longer lists packages whose only other version is one. An entry in a catalog is still moved down.bun audit fix: after it upgrades a package past a plugin's peer range, the "Fixed / remaining" counts and the exit code match the nextbun audit, and the plugin's line is marked(peer).--dry-runsays the same as the real run, except when the narrow peer range is in one of the project's ownpackage.jsonfiles.bun auditreported "No vulnerabilities found" on an empty answer. It'serror: <registry> returned an empty audit response, exit 1, also with--jsonandfix(for a scoped registry, the existing warning).{}still means none found.bun pm version <increment>computes the same version asnpm version(1.0.0-rc.1+majoris1.0.0). It cleansv2.0.0to2.0.0, and rejects2,x, ranges, a bad--preid(also--preid 01, a number with a leading zero) and, withfrom-git, a tag that isn't a version.bun pm ls/bun listsupport--production,--omit,--depth=0and package names (bun pm ls lodash). This covers part ofbun pm lsdoesn’t support naming a package to list #13148.bun pm licensesskipped an installed package whose own version differs frombun.lock(a bundled copy, another spelling). It lists it under its own version.--dry-runprinted one line per dependency edge, skipped peers and ignored the platform. It lists what the install would put innode_modules, each package once (not yet narrowed by--filter).bun pm cache rmprints "Cleared" only on success.bun pm cache pack/unpackcrashed while reporting a file name that isn't UTF-8.bun infoandbun createcrashed on a name longer than a path.bun pmsub-command (bun pm ls --json) was silently ignored. It's an error that names the sub-commands that take it.bun pm diff a b > changes.patchapplies withgit applyandpatch -p1when a version adds or removes an empty file, changes an executable bit, or has file names with spaces (they're C-quoted). Binary files and source maps keepdiff --bun.bun pm diff <pkg>compared the first lockfile entry of that name. It uses the version<pkg>means in the workspace you run it from, accepts an alias, andbun pm diff <pkg> 2.0.0starts from the installed version.bun pm diffcompares style sheets that containurl()by their canonical print too.package.jsonturned control characters such as\^[into\x1Bor\v, which npm and node can't parse.Registry requests and the manifest cache
bun publishdropped the registry token on a redirect from http to https on the same host and port. They keep it, asbun installdoes.NO_PROXYfor the new URL. Each hop picks its proxy by its own URL, as infetch().TooManyRedirects, without retries.--offline. It leaves them, and the next fetch overwrites them.Configuration (
bunfig.toml,.npmrc, flags)bunfig.tomlor.npmrcused to be a warning. It'serror: This file cannot be read, and bun does not install packages without its settings, before any request. Commands that neither install nor publish still warn and continue, and auto-install turns itself off.cafile,cache,globalDirorglobalBinDirinbunfig.tomlor.npmrcis relative to that file, wherever the command is typed. A relativecafileonly worked from the project root.--config,--cache-diror--cafileis relative to the directory the command is typed in, not the project root.BUN_INSTALL,XDG_CACHE_HOME,BUN_INSTALL_CACHE_DIR,BUN_INSTALL_GLOBAL_DIR,BUN_INSTALL_BINandNPM_CONFIG_USERCONFIGaccept a leading~/. A relative value keeps its current base (the project root for the cache).BUN_CONFIG_REGISTRY,NPM_CONFIG_REGISTRYor--registry. With credentials of its own it leaves the configured host for no other.--dry-run(anddryRun = true) was accepted and ignored bybun pm fetch,bun pm cache pack/unpack,bun patchand--commit.bun patch <pkg> --dry-runeven discarded edits. They print what they would do and leave the project alone.bun install --analyzeandbun add --analyzeskipped packages that are imported only by a subpath (lodash/debounce). An unresolved@/aliasimport no longer aborts the run, and a file that imports the package it belongs to no longer gets that name looked up or added.Messages and diagnostics
\x1b,\r,\^[, bidirectional marks) inbun pm pack,publish,audit fix,prune,pm whoami,run,create,pm migrate, in error messages and in source excerpts (a NUL in an excerpt stays).--jsonis untouched.bun installsilently skipped parts of a patch it can't apply: aBinary files ... differsection, a file copy, colored output, stray text. It still installs, and warns about each one. It fails on aGIT binary patchsection or a hunk without a file.patchedDependencieskey without a version was silently not applied. It gets a warning that points at the key.@no longer gets a false one on every install.bun patchprints a note when the package has trusted install scripts: they haven't run on the fresh copy, and run again at--commit.bun patch <transitive dependency>prints that dependents only see the changes after--commit.bun patchand--commitfail withENAMETOOLONGinstead of crashing when a path argument or--patches-diris longer thanPATH_MAX..npmrcshow its absolute path, as forbunfig.tomland~/.npmrc."git restore" for "x" failed) instead of "git checkout".Windows
Found by @dylan-conway in review, by hand, on CI's Windows builds, and tested again the same way on
ce845c1e2: of 52 cases 35 go from fail to pass, 15 controls pass on both, none goes from pass to fail.bun patchfailed withEPERMwhile a program had a file of the package open (a file opened without sharing still fails, withEBUSYand the folder left whole); switching linkers with one file open stopped half way and left packages missing.XDG_CONFIG_HOMEorUSERPROFILEwithout a drive letter, or on a share that doesn't exist, stopped every install with "cannot be read". An odd error counts only if the file is really there.NUL).node_modulesthat is a junction or a directory symlink, the isolated linker writes absolute link targets, so the links resolve.file:folder were taken to "lead out of the project" when the command was typed inc:\projforC:\proj, or through a junction.--patches-dirtakes/,\and.\, and always writes/topackage.jsonandbun.lock.preversion/version/postversionscripts ofbun pm versionin a git repository ran with an empty environment.node_modules\.binahead of the systemPATHwhenPATHspelled it in another letter case.bun create <local template>failed with "ENOENT: failed to copy file" when the working directory, the template or the destination has a non-ASCII character.Hardening
bun installextracts a few unusual tarball entries the way npm does, or skips them as npm does, and takes two zero blocks for the end of a package tarball (registry, URL andfile:tarballs). It reads a tarball to its end on every extraction path.bun patch --commitnames new patch files without it.InvalidURLbefore any connection is opened.package.jsonis always a regular file from its own repository. A cached checkout whosepackage.jsonis a link is checked out again when the dependency is resolved anew (nobun.lockentry,bun update,bun add).node_modules/.bundoesn't really live in the project's store (macOS, Linux).globalStore = true, packages that depend on each other are shared only between projects that link them to the same versions.yarn.lockkeeps the checksum of entries that have nointegrityline.onlyBuiltDependenciesas"trustedDependencies": []inpackage.json.bun pm trusttakes only its positional arguments as package names. It andbun add --trustleave blocked what atrustedDependenciesentry cannot unblock forbun install: a tarball, git,file:orlink:dependency that neither the project nor a workspace declares, and a package that another one ships inside itself.bun pm untrustedmarks the packages that can't be trusted by name.--installflag. It counts when set in the global bunfig, or in abunfig.tomlbetween the working directory or the importing file and the project root.bun patch,bun patch --commit,bun link <pkg>andbun deduperun the configured security scanner before they install packages.install.security.scannerpath in the global bunfig or in a--configfile is relative to that file. File names with quotes work.bun.lockfrom the project of the importing file, whereverbunwas started; abun.lockin an unrelated parent folder is ignored. Apackage.jsonthat only marks the module type (no name, workspaces or dependencies) is passed over when a real project is above it; otherwise the topmost one is the root.bun pm packnever packs its own temporary files.bun pm diffrequests and checks downloads the waybun installdoes (the registry's integrity, andbun.lock's when it's loaded).bun pm diff's terminal view checks what it folds away as "formatting only", and what it re-prints for minified files, against a full re-parse, and shows the plain diff when the check doesn't hold. The JavaScript parser gets one internal option for this (keep_directives); onlybun pm diffsets it.bun pm difftreats fewer files as binary and prints sizes and a sha256 for the ones that are. Itspackage.jsonnotes compare whole values and say where the registry's metadata and the tarball disagree on a field thatbun installuses. It escapes control characters on a terminal withNO_COLORtoo.Not in this PR
bun pm ls --jsonand--depth=Nabove 0 are rejected rather than supported (Separatebun pm lsoutput into dependencies, devDependencies, etc. and support--jsonoption #8283 stays open).bun unlink <name>is still not implemented.bun updatestill doesn't move a peer-only entry within its range (bun outdated doesn't update peer deps #13509).bun install;bun updateretries most of them.node_modulesfolder still ignorespackage.jsonandbun.lockfor a package that is missing on disk.Known to be still open
Reopened because the fix was taken out of this PR again (as on
main, unless noted):bun.lockcan give different versions.bun.lockchanges under an existingnode_modules(agit pull,rm bun.lock), a nested copy that the old lockfile didn't place can stay and shadow the right version. Simulated pulls that ended wrong: 101 of 697 onmain, 100 of 697 here. Therm bun.lockcase is new with install: consolidate the open package manager pull requests #44968..binand in the global bin folder.SIGINTlistener during auto-install's wait is handled only when the wait ends (30 s idle at most); before install: consolidate the open package manager pull requests #44968, at once.git pull) but never ran its scripts here:bun pm trustdoesn't run them.file:folder that is edited in place isn't built again by the next install (new with install: consolidate the open package manager pull requests #44968).bun patchfails for every package. A secondbun patch <pkg>discards uncommitted edits.binof a tarball, GitHub or git dependency isn't linked after ayarn.lockorpnpm-lock.yamlmigration: neither file records it.mainand in pnpm. npm leaves the optional package out and asks again on the next install.Regressions from #44968 that this PR doesn't fix:
bun removeemptiespackage.jsonbefore it writes it, so a full disk at that moment leaves an empty file.bun installwaits 7 to 9 s through its retries without printing anything.ENAMETOOLONGfrom 185 characters on (204 before).Gaps in what this PR adds:
node_modules, the hoisted linker replaces a folder or file that has the name of a dependency, as 1.4.3 and pnpm do; behind a workspace's linkmaindoesn't, because it replaces the link.bun add p@2 --filter amoves a sharednode_modules/pwithout laying the nested copy for a workspace outside the filter, until the next plain install.main: the install script of a deeply nested package can start while a folder above it is still being replaced (install --force,add,update), and fails because its own folder is gone.bun patchfails withEBUSY, the folder left whole, while another process has a file of the package open without sharing deletes, or has its working directory in the package (1.4.3 worked).--patches-dir ..\outsidefails, as before.How did you verify your code works?
cc9d7c2daand ofmainat the merge base. The head adds one fix, tobun add --trust, and a test.bun.lock,main/ branch: 6 / 0 of 950; 49 / 0 of 300 with many peers (8 + 8 runs); on the branch 0 of 1,400 with git, GitHub and tarball dependencies.add,remove,update, edits ofpackage.json, ...) on random projects, cold against warm: 1,260 cases, no difference. 7,640 pairs of a command and a registry fault: the exit codes ofmain, no hang. 16,148 installs with one package answering 404: none ends with anotherbun.lockand no message. 6,168 bit flips in cached manifests: no crash.main/ branch in ms: plain 1555 / 1505; three levels of peers 1603 / 1585; with one slow host 1900 / 1914; three remote tarballs that take 0.3 s 1588 / 1271, 1.5 s 1933 / 1893, 3 s 3426 / 3408.main, 306 on the branch. One that passes onmainfails here, on purpose: the error for a command typed in a linked workspace outside the project. The rest fail on both.main, one pass per kind of regression (deletes, credentials, loud to quiet, works to refused, lockfile compatibility, cost): about 95,000 differential cases, 364 real lockfiles and 9,571 real package folders found 22 regressions of this branch; each is fixed or listed above.mainmain--frozen-lockfilebun addnode_modules, cache warm--lockfile-onlybunxof a scoped or cached tool (+0.2 M, 35 system calls);bun pm untrusted(+5 %, one more hoist); an isolatedbun prunethat removes something (+4 %); auto-install in a workspace without a lockfile (+13 %; double at 300 workspaces); and the hoist named in the sign-off list. A warm hoisted install makes 8,326 system calls, not 10,434.main, taken over, then a pulledbun.lock: 17 end with a wrong version onmain, 21 here (the stale copy after a pull described above). Of planted folders that Bun didn't lay,mainloses 138, the branch none.bun pm versionagainstsemver.inc(0 of 1,530,270 differ); 1,260 tarballs extract as before; older builds ofmainleave a lockfile with the new keys unchanged.