Repository navigation
bunx: allow multiple packages in a single temporary execution environment - #39449
Open
loicnaoussi wants to merge 6 commits into
Open
loicnaoussi wants to merge 6 commits into
loicnaoussi wants to merge 6 commits into
Conversation
specified_package: Option<&[u8]> becomes specified_packages: Vec<&[u8]> so --package/-p can be given more than once. Every call site is updated to check emptiness instead of Option::is_some/is_none; behavior for zero or one --package is unchanged (opts.package_name still resolves to the first requested package). This is groundwork only: downstream install/cache-key logic still only consumes the first entry until the following commits.
UpdateRequest::parse now runs over the full specified_packages list (when non-empty) instead of always parsing just opts.package_name, so each --package gets its own parsed request. do_cache_bust/look_for_existing_bin move earlier and become aggregates over every request (any floating dist-tag busts the cache; all requests must want the cache path for it to be tried) instead of reading only the first request. They're computed before update_requests[0] is borrowed mutably, since that borrow is held for the rest of the function. For 0 or 1 --package this is behaviorally identical to the check it replaces.
…lues package_fmt (the cache directory key) and install_param (the bun add target) become package_fmt/install_params for 0 or 1 --package they are unchanged; for N > 1 the cache key is derived from the raw --package specifiers, sorted (so order doesn't create a second cache directory for the same package set) and hashed (so it stays short and filesystem-safe regardless of package name length or count), and install_params holds one raw specifier per package — bun add already parses each one itself, including github:/URL forms that don't reduce to a clean name. install_param is moved into install_params here, so log/error messages that displayed it now use install_param_display, a comma-joined string covering every requested package. The actual install argv still only installs the first entry — generalizing it to every install_params entry is the next commit.
The install argv now pushes every install_params entry (previously only index 0), so bun add actually receives all N packages from N --package flags in one invocation, into the same temporary node_modules. Swapped the fixed-size BoundedArray<_, 8> for a Vec<&[u8]> since the argv length is no longer bounded by a small constant, and dropped the now-unused BoundedArray import.
The "does not provide a binary named" message displayed only update_request.name (the first requested package), which is misleading once more than one --package can be given. Uses install_param_display (all requested packages, comma-joined) instead.
docs/pm/bunx.mdx: add a repeated --package example alongside the existing single-package one, and note that the binary must still be given explicitly and nothing is added to the project's dependencies. test/cli/install/bunx.test.ts: - CLI validation: multiple --package still requires an explicit binary name, same as a single --package. - Functional: two distinct packages, each with its own bin, installed together via `--package a --package b` and run from the shared environment; then re-run with the package order reversed asking for the *other* binary, asserting zero registry requests — the cache key must be order-independent for this to hold.
gberlian
pushed a commit
to gberlian/bun
that referenced
this pull request
Oct 14, 2026
### What does this PR do? Picked up from oven-sh#27452 by @ctjlewis (requested by @alii in oven-sh#27452 (comment)) so CI runs automatically and the autofixer works. All commits preserve original authorship (Lewis <lewis@spellcraft.org>). --- Adds `--path-ignore-patterns` argument and Bunfig option similar to `--coverage-path-ignore-patterns`. https://bun.com/docs/test/configuration#coverage-path-ignore-patterns - Closes oven-sh#27388 - Closes oven-sh#21395 - Closes oven-sh#13963 ### How did you verify your code works? Tests in `test/cli/test/path-ignore-patterns.test.ts` (328 lines). ### Docs Simple docs added for Bunfig and Configuration docs. ### Verification Buildkite oven-sh#39573 on `1a1af82`: only CI failure is a snapshot mismatch in `test/js/bun/test/snapshot-tests/snapshots/snapshot.test.ts` (111 passed, 1 failed snapshot) — completely unrelated to this PR. Main branch also failing on all recent commits (builds oven-sh#39449, oven-sh#39406, oven-sh#39511, oven-sh#39396). All 3 bot review threads resolved. Diff clean — no TODOs, changes scoped to bunfig parsing, CLI args, test scanner, docs, and tests. Ready for human review. --- **Verification (robobun):** CI green (13/13 on `525b4dd`). Diff clean — no TODOs, changes well-scoped to bunfig parsing, CLI args, test scanner, docs, and tests. All 3 bot review threads resolved (coderabbit precedence fix applied, trailing-slash pruning restricted to `**` patterns). Feature PR — tests confirm baked binary lacks the feature (9 fail) while CI passes all platform suites. --------- Co-authored-by: Lewis <lewis@spellcraft.org> Co-authored-by: Alistair Smith <alistair@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #39444 —
--package/-pcan now be repeated to install several packages into the same temporarybunxexecution environment, matchingnpx --package a --package b cmd.specified_package: Option<&[u8]>becomesspecified_packages: Vec<&[u8]>;--package/-p/--package=/-p=all accumulate instead of overwriting.--packagevalue is parsed into its ownUpdateRequestand passed tobun addas its own target (raw specifiers, unmodified —bun addalready parsesname@version,github:, URL forms itself, so no reconstruction needed). The install argv is aVecnow instead of a fixed-sizeBoundedArray<_, 8>, since the size is no longer bounded by a small constant.bunx-<uid>-<key>) is derived from the sorted, hashed set of raw--packagespecifiers when more than one is given, so--package a --package band--package b --package ashare one cache directory. For 0 or 1--packagethe key is byte-identical to before (existing caches aren't invalidated). The cache-clearing code inpackage_manager_command.rsonly matches thebunx-<uid>-prefix, so it needed no changes.do_cache_bust/look_for_existing_bin): aggregated across every requested package (any floating dist-tag busts the cache for the whole set) instead of reading only the first request.--package(existing behavior, unchanged), the binary to run must always be given explicitly — no bin-guessing is needed across multiple packages, since whichever package provides the named bin is found via the shared cache'snode_modules/.bin.Split into 6 commits by concern: CLI parsing → N-request parsing + cache-freshness aggregation → cache-key/install-target aggregation → generalizing the actual install argv → the missing-binary error message → docs/tests.
Test plan
test/cli/install/bunx.test.ts:--packagewithout a trailing binary name still errors, same message as a single--package.--package a --package b, binary from the first one runs; then re-run with the--packageorder reversed asking for the other binary — asserts zero registry requests, which only holds if the cache key is genuinely order-independent.docs/pm/bunx.mdx: added a repeated---packageexample next to the existing single-package one.I could not compile or run any of this locally — same constraint as on a recent PR in this repo: no
bun,cargo, or C++ toolchain available in this environment. I reviewed the Rust changes carefully by hand (borrow-checker implications of computingdo_cache_bust/look_for_existing_binbeforeupdate_requests[0]is borrowed mutably, theinstall_param→install_paramsmove and its downstream display-string uses,Vec<&[u8]>lifetime consistency), and independently re-derived the final diff twice (once as a single pass, once reconstructed commit-by-commit) to confirm both produce byte-identical output — but none of it has been checked by actually building.buildkite/bunpassing is load-bearing here.