Skip to content

Pi provider update hardcodes npm and fails when Pi is installed via bun #3119

Closed

Description

@adihex

Bug: Pi provider update hardcodes npm install -g and fails when Pi is installed via bun

Summary
bb updates apply / Pi provider maintenance always runs npm install -g @earendil-works/pi-coding-agent@latest, even when pi was installed via bun (~/.bun/bin/pi). The install succeeds to mise's npm prefix (~/.local/share/mise/installs/node/.../lib/node_modules) which which pi never resolves to. pi --version stays stale, so bb reports 0.84.4 → 0.85.0 Failed — pi update exited successfully, but the provider could not verify the installed result.

Repro

  1. Install pi via bun (as https://pi.dev recommends): bun add -g @earendil-works/pi-coding-agent → pi at ~/.bun/bin/pi → ~/bin/pi shim wraps it
  2. bb updates status shows update available 0.84.4 → 0.85.0
  3. bb updates apply runs npm install -g @earendil-works/pi-coding-agent@latest (167 packages, success)
  4. pi --version still 0.84.4, ~/.bun/install/global/.../package.json still 0.84.4
  5. bun add -g @earendil-works/pi-coding-agent@latest is what actually updates it to 0.85.0

Environment

  • macOS Darwin, mise node 22.23.0 (npm prefix -g = ~/.local/share/mise/installs/node/22.23.0)
  • which -a pi: ~/bin/pi → ~/.bun/bin/pi (first), ~/.local/share/mise/shims/pi, ~/.bun/bin/pi, ~/.local/bin/pi
  • cat ~/bin/pi = exec "$HOME/.bun/bin/pi" "$@"
  • bb 0.42.0, provider-pi PI_NPM_PACKAGE=@earendil-works/pi-coding-agent

Root cause
packages/provider-pi/src/bridge/provider-maintenance.ts (built to server/dist/builtin-plugins/provider-pi/dist/host.js):

  • npmCommand() / npmGlobalInstallCommand() hardcoded
  • getPiProviderInstallationStatus() only probes npm prefix -g + npm list -g, sets installSource via npmGlobalInstallSource()
  • installAction.command and getPiProviderInstallationRun().command always npm install -g
  • Verification expects version bump after npm, so bun installs never verify

Proposed fix
Detect install source and match the package manager:

function bunCommand() { return "bun"; }
function bunGlobalInstallCommand(pkg: string) {
  return { command: "bun", args: ["add","-g", `${pkg}@latest`], displayCommand: "bun add -g ..."};
}
function isBunInstalledPi(executablePath: string | null): boolean {
  // realpath + shim content check + ~/.bun/install/global/.../package.json existence
  // if executable resolves inside ~/.bun or shim wraps bun, or bun global pkg exists → true
}
function piInstallCommand(pkg: string, executablePath: string | null) {
  return isBunInstalledPi(executablePath) ? bunGlobalInstallCommand(pkg) : npmGlobalInstallCommand(pkg);
}

Then:

  • getPiProviderInstallationStatus() → installAction.command = piInstallCommand(PI_NPM_PACKAGE, resolvedExecutable).displayCommand
  • getPiProviderInstallationRun() → command = piInstallCommand(PI_NPM_PACKAGE, status.executablePath)
  • Optionally probe bun similarly (bun pm pkg / check ~/.bun/install/global/node_modules/...) for npmGlobalPackageVersion equivalent, or at least don't treat bun installs as external.

Fallback also fine: if bun --version succeeds and ~/.bun/bin/pi exists, prefer bun. If neither, keep npm.

Local workaround patched
Applied to /Applications/bb.app/.../provider-pi/dist/host.js (inserted helpers above, 901B delta) — bb updates status now 0.85.0 Up to date and future updates will use bun add -g when pi is bun-installed.

Checklist

  • Detect bun vs npm in provider-maintenance.ts
  • probeBunGlobalPackage() or fs check for bun global
  • Unit test: which pi → bun shim still picks bun

Activity

  1. added theissue type on Sep 5, 2026
  2. added
    providers
    provider-pi
    confirmed-repro
    on Sep 5, 2026
  3. bb-slop-cop commented on Sep 5, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classified Bug · Priority Medium · Effort Low · labels providers, provider-pi, confirmed-repro.

    Report: https://get-bb.github.io/reports/issues/3119.html — REPRODUCED with high root-cause confidence.

    Root cause: Pi maintenance resolved the active executable but constructed both the displayed update action and executable plan with npm unconditionally. A focused wrapper-to-Bun regression test failed twice on clean trusted checkouts at 7d5de7301, then passed after the contained fix.

    Ready pull request: #3121

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions