Skip to content

Login-shell PATH probe keeps the incomplete -lc PATH when -ilc times out, so a provider that is found but needs .zshrc PATH entries fails until restart #6586

Open

Description

@pascal-de-ladurantaye

Summary

When the login-shell PATH probe's interactive attempt ($SHELL -ilc) times out, for example under heavy load right after a reboot, bb falls back to $SHELL -lc and keeps that PATH. That PATH comes from .zprofile only and is missing everything .zshrc adds. If the provider CLI itself is on the -lc PATH but something it runs is only on the .zshrc PATH, bb finds the CLI, the CLI exits with code 1, and bb never re-reads the shell. In my case every pi thread failed to start until I restarted bb. Expected: bb notices that the fallback PATH is incomplete and probes again with the interactive shell once it can.

Versions and environment

  • bb 0.48.0 (desktop app, launched as a login item at boot), macOS on Apple Silicon
  • provider-pi, pi 1.4.0 (behind a wrapper script that runs a helper CLI at startup)
  • zsh login shell: .zprofile puts pi on PATH for non-interactive shells, .zshrc adds the helper's directory. zsh -ilc true takes about 1.7 s on an idle machine.
  • Code checked against main at 2096c06

Steps to reproduce

Real host (observed):

  1. Use a login shell whose .zprofile puts the provider CLI on PATH and whose .zshrc adds a directory with a helper the CLI runs. .zshrc takes more than 3 s under load.
  2. Reboot, with bb starting at login. Load average was about 12 during the first minutes.
  3. Start a pi thread.

Minimal repro against HostToolchain on main (packages/process-utils/src/host-toolchain.ts). It uses a throwaway ZDOTDIR: .zprofile adds profilebin (holds agent), .zshrc adds rcbin (holds helper, which agent needs) and sleeps 4 s while a slow flag file exists.

R=$(mktemp -d); mkdir -p $R/home/profilebin $R/home/rcbin
printf '#!/bin/sh\ncommand -v helper >/dev/null || { echo "agent: helper not found on PATH" >&2; exit 1; }\necho ok\n' > $R/home/profilebin/agent
printf '#!/bin/sh\nexit 0\n' > $R/home/rcbin/helper
chmod +x $R/home/profilebin/agent $R/home/rcbin/helper
echo "export PATH=\"$R/home/profilebin:\$PATH\"" > $R/home/.zprofile
printf '[ -f "%s/slow" ] && sleep 4\nexport PATH="%s/home/rcbin:$PATH"\n' $R $R > $R/home/.zshrc

Save as repro.mts at the root of a checkout with dependencies installed, then run R=$R pnpm exec tsx repro.mts:

import { spawnSync } from "node:child_process";
import { writeFileSync, rmSync } from "node:fs";
import { HostToolchain } from "./packages/process-utils/src/host-toolchain.ts";
const R = process.env.R!;
const base = { HOME: R + "/home", ZDOTDIR: R + "/home", SHELL: "/bin/zsh", USER: process.env.USER, PATH: "/usr/bin:/bin:/usr/sbin:/sbin" };
const run = (tc: HostToolchain, label: string) => {
  const c = tc.command("agent");
  const r = spawnSync(c.command, c.args, { env: c.env, encoding: "utf8" });
  console.log(label, "| resolved:", c.command, "| exit:", r.status, "|", (r.stdout + r.stderr).trim());
};
writeFileSync(R + "/slow", "");            // interactive rc file is slow (boot load)
const tc = new HostToolchain(base, process.execPath);
let t = Date.now(); await tc.refresh(); console.log("startup probe took", Date.now() - t, "ms");
run(tc, "1. after startup probe");
await tc.refresh(); run(tc, "2. refresh while still slow");
rmSync(R + "/slow");                         // load settles
tc.invalidateFailure(1); await new Promise(r => setTimeout(r, 2500));
run(tc, "3. load settled, only invalidateFailure(exit 1)");
await tc.refresh(); run(tc, "4. after explicit refresh()");

Did not reproduce: with no slow flag (the -ilc probe finishes in time), agent exits 0 from the first run. Restarting bb on the real host also fixed it.

Expected vs actual

Actual, repro on main:

startup probe took 3027 ms
1. after startup probe | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
2. refresh while still slow | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
3. load settled, only invalidateFailure(exit 1) | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
4. after explicit refresh() | resolved: $R/home/profilebin/agent | exit: 0 | ok

Actual, real host (~/.bb/logs/host-daemon.3.log, boot at 17:04:09, bb restarted by hand at 17:12:48):

17:05:56 provider.list_models: Could not determine the pi version: `pi --version` exited with 1.
17:06:14 turn.submit: pi exited (code 1, signal null): Error: <wrapper's helper failed: helper not on PATH>
17:07:11 turn.submit: same
17:09:13 turn.submit: same

Expected: when the -ilc probe times out, the -lc PATH is used only until a later interactive probe succeeds. A provider that exits right away after spawning (or a turn that fails to start) triggers that probe, and the next turn gets the full PATH without restarting bb.

Evidence

  • The probe timeout is 3 s:
    const PROBE_TIMEOUT_MS = 3000;
  • In the first probe, a timed-out -ilc falls through to -lc, and whatever PATH that returns is kept:
    const shellArgs = ["sh", "dash"].includes(basename(shell))
    ? ["-lc"]
    : ["-ilc", "-lc"];
    for (const arg of shellArgs) {
    const result = await runProbe(shell, [arg, command], env);
    if (result.status !== 0) {
    if (retainPrevious) return null;
    continue;
    }
    const start = result.stdout.indexOf(`${SHELL_START}\n`);
    const end = result.stdout.indexOf(`\n${SHELL_END}`, start);
    if (start < 0 || end < 0) {
    if (retainPrevious) return null;
    continue;
    }
    const values: NodeJS.ProcessEnv = {};
    for (const line of result.stdout
    .slice(start + SHELL_START.length + 1, end)
    .split("\n")) {
    const separator = line.indexOf("=");
    const key = line.slice(0, separator);
    if (key === "PATH" || NETWORK_KEYS.includes(key))
    values[key] = line.slice(separator + 1);
    }
    if (values.PATH) return values;
  • Later refreshes run with retainPrevious, so a -ilc that times out again keeps the incomplete -lc PATH:
    const retainPrevious = this.shellEnv.PATH !== undefined;
    this.refreshing = readShellEnvironment(this.baseEnv, retainPrevious)
    .then((env) => {
    and
    const result = await runProbe(shell, [arg, command], env);
    if (result.status !== 0) {
    if (retainPrevious) return null;
    continue;
  • invalidateFailure refreshes only on ENOENT or exit 127. A CLI that is found and exits with 1 never triggers a refresh:
    invalidateFailure(errorOrCode: unknown): void {
    const code =
    typeof errorOrCode === "object" &&
    errorOrCode !== null &&
    "code" in errorOrCode
    ? errorOrCode.code
    : errorOrCode;
    if (code === "ENOENT" || code === 127) void this.refresh();
    }
  • After the reboot I rebuilt the zsh -lc PATH by hand and ran pi --version with it. That printed the same error. Adding the helper's directory made it print 1.4.0.
  • bb thread: thr_348ecrgmk2

What you ruled out

Suggested priority and effort

Medium. It hits anyone whose .zshrc is slow at boot and adds PATH entries their provider needs, and every thread fails until bb restarts. There's a workaround (dotfiles or a restart), and no data is lost. Effort is probably low to medium: re-probe -ilc after a fallback or timeout, or raise the timeout at startup.

Checks

  • I reproduced this on main at 2096c06 (code-level repro above) and on the real host with bb 0.48.0.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

AGENT GENERATED

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low. Applied host, providers, and provider-pi; no existing classifications were replaced.
    • Report: https://get-bb.github.io/reports/issues/6586.html
    • Verdict: REPRODUCED · high root-cause confidence · confirmed-repro. Both authored regression cases fail on trusted origin/main in two separate clean-base checkouts.
    • Root cause: fallback shell discovery loses its provenance; an already-resolved command exiting 1 does not trigger recovery of the missing helper PATH. The original macOS/provider incident and daemon refresh propagation remain unverified.
    • No PR: the local prototype passes both regressions, but the required existing-suite gate fails on an unchanged-production test too: the host-installed Claude CLI shadows its fixture. The stopped fix was not pushed.

    AGENT GENERATED

  4. added a commit that references this issue on Nov 16, 2026
    6755bb0
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-reprohostprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions