Repository navigation
Description
Summary
The bb host daemon builds the PATH it hands to provider bridges, plugin workers, terminals, and setup hooks from a one-shot login-shell probe taken at daemon startup (runtime-shell-env.ts). When that probe fails or times out - which is easy on macOS, where the interactive probe ($SHELL -ilc) regularly takes 1.2-1.9 s against the 3 s timeout and can exceed it while the machine is under load at login - the daemon silently falls back to its own bare launchd PATH (/usr/bin:/bin:/usr/sbin:/sbin). Every provider CLI lookup then fails ("bb could not find the Codex CLI", "spawn cursor-agent ENOENT") even though the CLIs are installed, until the daemon happens to be restarted at a moment the probe succeeds.
Two aggravating design issues:
- The startup fallback is captured once and kept.
resolveUserShellPathWithPreviouscachespreviousPathonly on success, so after a failed startup probe the effective PATH stays the broken daemon PATH until a later refresh succeeds - and the machine-environment layer (machine-environment.ts) falls back to exactly that captured value whenever a managedPATHvariable is removed from Settings -> Environment variables. - The non-interactive fallback probe (
-lc) omits anything configured in~/.zshrc. On macOS the Claude Code installer instructs users to add~/.local/binto~/.zshrc, and tools like bun/opencode often live there too.-lcsources.zprofile/.zshenvbut not.zshrc, so a "successful" probe via the-lcfallback still cannot findclaude.
This is invisible while a global machine environment PATH variable exists (it overrides the broken shell PATH for every bb shell), which is why it surfaces as "removing the synced PATH broke codex/claude on my Mac." Removing the variable is correct; the daemon fallback PATH is what is broken.
Versions and environment
- bb 0.45.0 (desktop app on macOS, enrolled host daemon via the
app.getbb.host-daemonlaunchd service; bb-app npm package 0.45.0) - macOS (Darwin 25.6.0), Node 22.22.0
- Providers: claude-code (claude 2.1.296 at
~/.local/bin/claude), codex (codex-cli 0.159.0 at/opt/homebrew/bin/codex) - Host daemon started by launchd with
PATH=/usr/bin:/bin:/usr/sbin:/sbin,SHELL=/bin/zsh
Steps to reproduce
- Enroll a macOS machine so the host daemon runs from launchd (bare
PATH, no user shell env). - Ensure
~/.zshrcadds~/.local/bin(the Claude Code installer default) and that the daemon starts while the machine is busy enough that$SHELL -ilcexceeds 3 s (measured 1.9 s idle; boot/login storms exceed it). - Observe the daemon captured shell env: a plugin/bridge worker spawned afterwards has
PATH=<bb dist dir>:/usr/bin:/bin:/usr/sbin:/sbin(viaps eww <worker-pid>). - Start a codex or claude-code thread: the turn fails with "bb could not find the Codex CLI on this machine" / "spawn claude ENOENT".
- Restart the daemon (
launchctl kickstart -k gui/$(id -u)/app.getbb.host-daemon.<server>-<hostId>) when the machine is idle: workers now get the full login-shell PATH and the same providers work immediately, with no other change.
Also reproducible purely at the probe layer:
# ~1.9s idle on macOS - the 3s timeout has little headroom under load
time /bin/zsh -ilc true
# -lc fallback omits ~/.zshrc entries:
/bin/zsh -ilc 'env' | grep '^PATH=' | tr ':' '\n' | grep -c '.local/bin' # 1
/bin/zsh -lc 'env' | grep '^PATH=' | tr ':' '\n' | grep -c '.local/bin' # 0Expected vs actual
Expected: bb shells always carry at least the user's login-shell PATH; if the interactive probe times out, the fallback should still include the directories users are told to put CLIs in, and the daemon should retry the probe rather than keep a broken capture.
Actual (worker env captured with ps eww after a failed startup probe):
PATH=/Users/alecf/.bb/npm/lib/node_modules/bb-app/host-daemon/dist:/usr/bin:/bin:/usr/sbin:/sbin
Corresponding provider failures in ~/.bb/logs/host-daemon.8.log:
{"level":40,"type":"provider.list_models","err":{"message":"bb could not find the Codex CLI on this machine. Install Codex (https://developers.openai.com/codex/cli) or put `codex` on PATH, then retry."}}
{"level":40,"type":"provider.list_models","err":{"message":"spawn cursor-agent ENOENT"}}
After a daemon restart at an idle moment, the same worker class gets:
PATH=/Users/alecf/.bb/npm/lib/node_modules/bb-app/host-daemon/dist:/Users/alecf/.bun/bin:...:/Users/alecf/.local/bin:...:/opt/homebrew/bin:...
and codex/claude-code work with no other change.
Evidence
- Probe + fallback:
apps/host-daemon/src/runtime-shell-env.ts-USER_SHELL_ENV_TIMEOUT_MS = 3_000at; arg setsconst USER_SHELL_ENV_TIMEOUT_MS = 3_000; -ilcthen-lcinuserShellEnvArgSets(same file, ~L313);prepareRuntimeShellEnvfalling back toprocess.env.PATHatapps/host-daemon/src/start-host-daemon.ts#L160((await resolveUserShellPath()) ?? process.env.PATH). - Machine-environment interaction:
apps/host-daemon/src/machine-environment.ts#L32-40(shellEnvironment) - when a managedPATHvariable is removed, shells fall back tooriginalShell.PATH, i.e. the startup capture; if that was the failed-probe fallback, removing the variable surfaces the breakage. - Observed on bb 0.45.0: daemon started Oct 5 from launchd; worker spawned Oct 9 with the bare PATH (above); errors
provider.list_models"could not find the Codex CLI" / "spawn cursor-agent ENOENT" in~/.bb/logs/host-daemon.8.log;launchctl kickstart -kon the daemon fixed both providers with zero other changes. - Timing measurement:
/bin/zsh -ilc truetook 1.2-1.9 s real on an idle M3 Pro; the 3 s timeout leaves about 1 s of headroom.
What you ruled out
- Not a provider-plugin bug: the binaries resolve fine when run with the post-restart worker PATH (
claude --version-> 2.1.296,codex --version-> 0.159.0). - Not caused by removing a global machine-environment
PATHvariable per se: that removal is what exposed this; the daemon-side fallback PATH was already broken, and the synced PATH had been masking it on every bb shell. - Not Windows-specific; this is the macOS launchd daemon path.
- Related but distinct from Packaged Nightly plugin processes lose PATH for node and gh #2343 (Nightly plugin processes losing PATH) and Agent threads: bb puts its CLI first on PATH, shadowing Babashka (
bb) and breaking#!/usr/bin/env bbscripts #4417 (bb CLI shadowingbb) - this is the daemon login-shell probe being a single point of failure with a bare-shell fallback.
Suggested priority and effort
Medium: hits any macOS (and likely Linux systemd) enrolled host whose daemon starts under a stripped environment while the interactive probe times out - common right after boot/login. User-visible symptom is providers "not installed" though they are. A restart workaround exists but is undiscoverable. Likely fixes (maintainer's call): retry the probe with backoff before settling for process.env.PATH, raise the timeout, and/or merge probe results across -ilc/-lc attempts instead of first-win; optionally re-probe periodically rather than caching the startup capture indefinitely.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 9, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,providers,partial-repro.ENOENTafter a successful shell refresh: removing a managed PATH causes the machine-environment overlay to restore its stale startup snapshot. Three control cases pass in each run; 35 relevant existing tests pass.maxweissenbaeck commentedon Oct 19, 2026
Native macOS repro with a real provider, in case it helps close the "unverified" part.
Setup: BB 0.46.1, macOS 27 (Apple Silicon). This Mac is an execution host of a remote BB server on another Mac, reached over Tailscale. The local host daemon runs as a LaunchAgent (
app.getbb.host-daemon.<server>-<host-id>.plist) whoseEnvironmentVariablescontain onlyBB_APP_NPM_PREFIXandBB_DATA_DIR, noPATH. Codex (v0.163.0) is installed through npm under nvm.Repro: a normal reboot. At the login start,
ps ewwshowed the daemon and its provider bridge worker withPATH=/usr/bin:/bin:/usr/sbin:/sbin. Every Codex turn then failed:The Mac was under very heavy load right after login (load average ~250 from Spotlight and post-boot indexing), which may be why the login-shell probe failed. Before the reboot, the daemon had been started from a shell and had the full PATH, so it only broke at the first launchd login start.
What didn't help: quitting and reopening the BB desktop app (twice). The app's own processes got the full login PATH, but the LaunchAgent daemon that runs the provider work wasn't restarted.
What fixed it:
bb machine env set PATH(global) with the login PATH, thenlaunchctl kickstart -k gui/$UID/<host-daemon label>. After that, the daemon process itself still showed the bare PATH, but the provider bridge worker had the machine-env PATH and Codex turns started again. (Not yet verified across a second reboot.)Suggestions: retry the login-shell probe (or fall back to
path_helperand the common Homebrew/nvm locations) when it fails at startup, writePATHinto the LaunchAgent plist at enrollment, and name the searched PATH in the ENOENT error.ymichael commentedon Nov 17, 2026
#6194 replaced the bare launchd fallback. What's left is tracked in #6586. Closing as a duplicate.
-lcPATH when-ilctimes out, so a provider that is found but needs.zshrcPATH entries fails until restart #6586