Skip to content

Deduplicate package manager and CLI command helpers#32022

Open
alii wants to merge 5 commits into
claude/split/foundationsfrom
claude/split/install-cli
Open

Deduplicate package manager and CLI command helpers#32022
alii wants to merge 5 commits into
claude/split/foundationsfrom
claude/split/install-cli

Conversation

@alii

@alii alii commented Jun 9, 2026

Copy link
Copy Markdown
Member

What this does

Consolidates duplicated blocks across the package manager and CLI commands (bun install/add/update/link/unlink/outdated/update --interactive/pack/bunx/create/run --filter|--parallel|--sequential/repl): shared workspace enumeration (src/runtime/cli/workspace_helpers.rs), shared run-process plumbing (src/runtime/cli/run_processes_shared.rs), the workspace package.json load-or-exit helper, and hosted_git_info/npm/yarn dedups. Net -1.2k lines (+2223/-3430).

Stacked on #32000 (foundations), merge that first. Split from #31912 (whole-repo simplification pass, closed in favor of module-scoped splits). This PR only moves and removes code, zero intended behavior change.

Behavioral equivalence

Audited hunk by hunk against the base: error messages, log-flush order, and exit semantics are byte-identical at every call site, with three reviewed edge-path exceptions:

  1. bunx: the second cached-bin probe (the package.json bin-name retry) now builds its probe path with the platform separator, matching the first probe; it previously used literal /. On Windows the probe string changes bytes but names the same file: which_win takes the absolute-path branch and every consumer (exists check, stat, CreateProcessW) accepts both separators.
  2. The shared get_with_path_or_exit and load_lockfile_or_crash helpers ignore a failed Log::print to stderr where two of the replaced sites propagated it with ?. That error path is unreachable: the writer behind Output::error_writer() deliberately discards fd write failures and always returns Ok (adapter_write_all in src/sys/lib.rs), so the old ? was dead code.
  3. bun update --interactive with --filter now routes WorkspaceFilter::init allocation failure through bun_core::handle_oom (matching bun outdated) instead of .expect("OOM").

Where the original duplicates genuinely differed (trusted-deps lockfile gating in PackageInstaller, the per-backend Windows walkers, the two PackageManager init paths, gitlab's distinct URL extractor), the helpers parameterize the difference instead of collapsing it.

Verification

  • Debug-build runs of the touched suites: hosted-git-info, yarn-lock migration, bun-install, bun-add/remove/update, bun-patch + bun-install-patch, bun-pack, bun-link, bunx, bun-create, isolated-install, bun-workspaces, lifecycle scripts, outdated, update-interactive, bun-run, filter-workspace + multi-run, repl. Every failure reproduces identically on the released bun or on a base-branch debug build (network-dependent fixtures, sandbox registry setup, and debug-only artifacts such as the install-failure trace dump and 5s timeouts on chains of debug-binary startups).

  • CI build 61502: the only failing test is bunx "should handle package that requires node 24", which fails identically on the base branch build (61499), is tracked in CI: bunx.test.ts fails on all platforms — @angular/cli@latest now requires Node >= 24.15.0, bun reports 24.3.0 #31797 (live @angular/cli@latest requires a newer Node than bun reports), and has a pending fix in test: pin @angular/cli version in bunx node-version test #31820. The flaky-retry annotations are on files this PR does not touch.

  • New hermetic tests pin the consolidated error exits: package.json name validation shared by bun link/bun unlink (bun-link.test.ts), the pack package.json parse failure (bun-pack.test.ts), and the missing-lockfile error shared by bun outdated and bun update --interactive (bun-install-registry.test.ts, update_interactive_install.test.ts).

@alii

alii commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@robobun adopt

@robobun

robobun commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Audit done: the diff is behavior-preserving (three edge-path notes documented in the PR body), local runs of all touched suites show no regressions against the base build, and hermetic tests pin the consolidated error exits. Build 61709 finished with only unrelated red: the streams-leak.test.ts flake on one Linux baseline lane (file untouched by this PR, also flaked on the base PR build) and two darwin 14 aarch64 test jobs that expired waiting for agents. Retrying those jobs in Buildkite should go green.

@robobun

robobun commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator
Updated 3:17 AM PT - Jun 10th, 2026

@robobun, your commit fbe8f1a has 1 failures in Build #61709 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 32022

That installs a local version of the PR into your bun-32022 executable, so you can run:

bun-32022 --bun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants