Skip to content

Pi model list fails: catalog child inherits stale PI_BB_TOOLS_FILE from app environment (ENOENT) #5351

Closed

Description

@cameronm123

Symptom

The model picker for the Pi provider shows:

Could not load models for Pi.
pi exited (code 1, signal null): Error: Failed to load extension
"/…/bb-provider-bridge-provider-pi-<A>/pi/bb-pi-extension.mjs":
Failed to load extension: ENOENT: no such file or directory, open
'/…/bb-provider-bridge-provider-pi-<B>/pi/pi-tools-<pid>-<ts>.json'

Pi threads themselves keep working; only provider.list_models fails.

Environment: bb 0.46.0, macOS 27.0, pi 1.1.0, builtin provider-pi plugin.

Root cause

Two problems combine.

1. Provider-scoped env froze into the whole app tree.
The bb app was at some point (re)launched from a process running inside a Pi bridge session context, so its environment contained that session's PI_BB_TOOLS_FILE — a temp manifest path inside that bridge worker's mkdtemp dir. The variable then propagated to every descendant: Electron main → bb-app-bridge → server → host daemon → all provider bridge workers. Verified live with ps eww: the same stale PI_BB_TOOLS_FILE was present on the app main process, the server, the host daemon, and freshly spawned provider-pi bridge workers, while the referenced file no longer existed (bridge workers rm -rf their temp dir on exit, so the path is guaranteed stale once that worker dies).

2. The catalog spawn does not override PI_BB_TOOLS_FILE.
In provider-pi, per-thread session spawns write a fresh pi-tools-*.json into the worker scratch dir and pass PI_BB_TOOLS_FILE explicitly. The model-catalog child, however, is spawned with buildPiChildEnv({}) and no override, so it inherits the worker's own environment. The bb pi extension reads PI_BB_TOOLS_FILE at load time → ENOENT → pi exits 1 → provider.list_models fails.

Suggested fixes

  1. spawnCatalog should pass a fresh tools manifest the way session spawns do — or buildPiChildEnv should drop PI_BB_TOOLS_FILE when the spawn does not supply one. The second option is more robust against any stale inherited value.
  2. Sanitize provider-scoped env in the app relaunch / daemon spawn paths — strip PI_* from inherited environment the same way BB_* is stripped from provider children — so launching bb from inside a provider session cannot freeze provider env into the app tree.

Workaround

Quit bb completely and relaunch it through LaunchServices (Dock/Finder, or open -a /Applications/bb.app from any shell — open does not forward the calling shell's environment). An in-process relaunch preserves the polluted environment and does not fix it.

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classification: Bug · Priority High · Effort Low · providers, provider-pi.

    Report: REPRODUCED — high root-cause confidence. Applied confirmed-repro after reproducing the failure in two clean trusted-main checkouts.

    Root cause: Catalog children inherit a deleted session tool-manifest path; the actual BB Pi extension opens it during initialization and exits with ENOENT. The reproduction exercises the real catalog and extension with the repository's Pi subprocess fixture; macOS relaunch ancestry remains unverified.

    Fix: PR #5352 drops only the inherited manifest path before applying explicit session overrides. The regression fails before the fix and passes afterward. All 7 catalog tests and 207 provider tests pass, with one Bun-specific skip; lint, typecheck, and three Pi parity recordings pass. Two files, 22 changed text lines. The PR is ready for review and has not been merged.

  4. cameronm123 commented on Oct 11, 2026

    @cameronm123
    Author

    Correction to the workaround: on macOS 27, open does forward the calling shell's environment to the launched app. We verified this live — relaunching bb via open -a /Applications/bb.app from a process whose env still carried the stale PI_BB_TOOLS_FILE reproduced the pollution in the freshly launched app (launchd session env was clean, no shell profile exports it). The workaround only works when the open call itself runs from a clean environment, e.g.:

    printenv | cut -d= -f1 | grep '^PI_' | while read -r v; do unset $v; done
    open -a /Applications/bb.app

    This also explains the original pollution entry: bb was launched (via open or an equivalent relaunch path) from a process running inside a Pi bridge session, which froze that session's PI_BB_TOOLS_FILE into the app environment. It strengthens suggested fix 2: the relaunch path should strip provider-scoped env (PI_*) explicitly rather than relying on LaunchServices to sanitize it.

  5. self-assigned this
    on Oct 14, 2026
  6. removed their assignment
    on Oct 14, 2026
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