#5955 · Unix provider updates bypass current-directory PATH entries
Trusted base: 405592c0b71b1655a6ab2e1cc7498b5beeb78caa (origin/main).
Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro
1. TL;DR
On Linux, provider installation can silently run a different executable, or report that an executable is missing, when PATH contains an empty component. The real host-daemon installation stream reproduces both outcomes with disposable shell executables. Its new unconditional command resolver drops empty PATH components, whereas Unix process lookup treats them as the working directory. The first and a second clean trusted checkout both fail three focused regression cases. Limiting installer pre-resolution to Windows restores the Unix process lookup without changing the shared portable execution helper.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Empty Unix PATH components stop locating a working-directory executable. | Verified on Linux | The trailing-component case emits a missing-command event. An explicit-directory control runs the same executable. |
| A later installation can be selected instead. | Verified | Leading and middle components run the fallback fixture and report success. |
| The new installer pre-resolution causes the regression. | Verified | The same stream and fixtures pass after changing only the platform guard in the spawner. |
| The behavior also affects macOS. | Runtime unverified | Source uses the same unconditional resolver. No macOS execution was available. |
| Windows executable and command-shim support must remain intact. | Preserved in source; runtime unverified | The Windows resolution branch and existing .exe/.cmd tests remain present. These two tests are skipped on Linux. |
3. Environment
- Public target repository: get-bb/bb; trusted base recorded above, fetched directly from its main branch.
- Linux 4.19.0-gvisor x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.1.
- Pinned dependencies: node-pty 1.2.0-beta.15 and which-command 0.1.0.
- Only disposable executable fixtures; no vendor CLI, provider credentials, production daemon, network installation, ports, or runtime data store.
- Both checkouts use frozen dependency installation and normal Turbo builds. The first full build encountered a missing SDK build output; an unchanged rerun succeeded, 67 tasks. The second clean build succeeded, 67 tasks.
4. Minimal reproduction
- Clone the public target and check out the recorded main commit in a disposable directory:
git clone https://github.com/get-bb/bb.git bb-path-repro cd bb-path-repro git checkout --detach 405592c0b71b1655a6ab2e1cc7498b5beeb78caa pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
If the initial parallel build reports that the installed plugin SDK dist is not yet built, rerun that same build after its SDK task completes. - Save the following independently authored reproduction as
repro.mjsat the checkout root. It calls the real exported host-daemon installation stream, not a model of its failure branch.import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; const checkout = process.cwd(); const { streamProviderInstallation } = await import( pathToFileURL(path.join(checkout, "apps/host-daemon/src/provider-installation.ts")).href ); const root = await fs.mkdtemp(path.join(os.tmpdir(), "bb-path-lookup-")); const fallback = path.join(root, "fallback"); const missing = path.join(root, "absent"); const command = "bb-path-order-fixture"; try { await fs.mkdir(fallback); for (const [directory, marker] of [[root, "local-install"], [fallback, "other-install"]]) { await fs.writeFile(path.join(directory, command), `#!/bin/sh\nprintf '${marker}:%s\\n' "$1"\n`, { mode: 0o755 }); } process.chdir(root); for (const [name, directories] of [ ["control", [root, fallback]], ["leading", ["", fallback]], ["middle", [missing, "", fallback]], ["trailing", [missing, ""]], ]) { const stream = streamProviderInstallation({ providerId: "path-lookup-fixture", plan: { command, args: ["update"], displayCommand: `${command} update` }, env: { ...process.env, PATH: directories.join(path.delimiter) }, }); const events = (await new Response(stream).text()).trim().split("\n").map(JSON.parse); const output = events.filter(event => event.type === "output").map(event => event.text).join("").trim(); console.log(JSON.stringify({ name, output, final: events.at(-1) })); } } finally { process.chdir(checkout); await fs.rm(root, { recursive: true, force: true }); } - Run
node --conditions=source --import tsx ./repro.mjs. Expected: all four cases printlocal-install:update, exitCode 0, success true. Actual on trusted main:{"name":"control","output":"local-install:update","final":{"type":"completed","provider":"path-lookup-fixture","exitCode":0,"signal":null,"success":true}} {"name":"leading","output":"other-install:update","final":{"type":"completed","provider":"path-lookup-fixture","exitCode":0,"signal":null,"success":true}} {"name":"middle","output":"other-install:update","final":{"type":"completed","provider":"path-lookup-fixture","exitCode":0,"signal":null,"success":true}} {"name":"trailing","output":"","final":{"type":"error","provider":"path-lookup-fixture","message":"Command not found: bb-path-order-fixture"}}
The regression test added to the existing host-daemon test owner exercises leading, middle, and trailing empty entries with real node-pty children. Leading/middle cases also install a competing executable later on PATH. It asserts local output, excludes fallback output, and requires a successful completion. Its working-directory mutation is restored in finally and automatically places the file in an isolated Vitest worker.
5. Root cause
The installer spawner resolves every command before spawning node-pty:
const command = resolvePortableCommand(args.command, { cwd, env });
if (command === undefined) {
throw new Error(`Command not found: ${args.command}`);
}
const pty = spawnPty(command, args.args, { ... });
resolvePortableCommand passes the supplied PATH to whichCommandSync. The installed which-command dependency deliberately skips empty components in its candidatePaths implementation. Thus a bare Unix command no longer reaches execvp lookup: the spawner either rejects it first or supplies an already selected fallback absolute path.
Dependency inspection confirms that Linux node-pty calls execvp after changing to its supplied cwd. Its macOS spawn helper also calls execvp, but that platform was not run. The helper's stricter lookup may be intentional for other consumers; the installer is the inappropriate cross-platform caller. No change to execPortableFile is needed.
6. Proposed fix and verification
Keep pre-resolution on Windows, where executable extensions matter, and pass the original command to node-pty on Unix:
const command =
process.platform === "win32"
? resolvePortableCommand(args.command, { cwd, env })
: args.command;
The local fix changes only the existing host-daemon spawner and its tests: 2 files, 62 changed text lines (56 additions + 6 deletions). No dependency, lockfile, generated output, stored data, public schema, protocol, packaging, or permission changes. A genuinely absent Unix command again terminates through node-pty with an unsuccessful completion; the existing missing-command test now checks that platform-specific behavior. Windows keeps its resolver-generated error.
Before production fix: pnpm exec turbo run test --filter=@bb/host-daemon -- provider-installation.test.ts 3 failed | 4 passed | 2 skipped leading/middle: expected 'other-install:update\r\n' to contain 'local-install:update' trailing: expected '' to contain 'local-install:update' After production fix: pnpm exec turbo run test --filter=@bb/host-daemon -- provider-installation.test.ts provider-installation-gate.test.ts 2 files passed; 20 tests passed | 2 Windows-only tests skipped pnpm exec turbo run typecheck --filter=@bb/host-daemon --filter=@bb/process-utils 6 successful tasks pnpm exec turbo run test typecheck --filter=@bb/host-daemon --filter=@bb/process-utils process-utils: 14 files passed | 1 skipped; 87 tests passed | 10 skipped host-daemon: 70 files passed | 2 failed; 797 tests passed | 2 failed | 7 skipped
The broader host suite has two unrelated environmental failures: a server-move unit-file mode check observes 0600 instead of 0644, and server-move inspection obtains null diskFreeBytes. Both fail identically on the second checkout's unchanged production code when running pnpm exec turbo run test --filter=@bb/host-daemon -- src/server-move (81 passed, 2 failed). They are not repaired here. Relevant installer tests and the complete process-utils suite pass. Native Windows/macOS verification remains unperformed.
7. Verification — second clean checkout
The same agent created a separate detached worktree at the recorded base. Frozen installation and Turbo build completed there. Only the newly authored regression-test patch was applied; production files remained byte-identical to trusted main. No service or port was started, and every test created fresh temporary fixture directories.
pnpm exec turbo run test --filter=@bb/host-daemon -- provider-installation.test.ts Test Files 1 failed Tests 3 failed | 4 passed | 2 skipped leading and middle: other-install:update trailing: no process output node --conditions=source --import tsx /path/to/repro.mjs control: local-install:update; completed success=true leading: other-install:update; completed success=true middle: other-install:update; completed success=true trailing: Command not found: bb-path-order-fixture
The exact standalone-script JSON is in section 4. On the fixed first checkout, all four script cases print local-install:update with successful completion. No correction to the Linux findings was required by the second run. This is a repeated reproduction by the same agent, not independent verification.
8. Related issues
The earlier Windows installer-resolution defect is tracked in #5428. That issue's platform is different; the present evidence covers a Unix lookup regression. No open pull request linking #5955 was found in its timeline, open-PR search, or open-PR closing-reference metadata during investigation. No linked PR code was checked out or executed.
9. Appendix and trust handling
The issue's scripts and requested implementation were treated as untrusted claims and not executed or copied. All execution used trusted origin/main, independently authored fixtures/tests, and the small local fix. Repository visibility was verified public before publication. Raw command logs and local reproduction artifacts stay outside this public report repository; reproducible code and relevant output are embedded above. No screenshots are needed for this nonvisual process-lookup bug.
Additional checks: refreshed origin/main still matched the recorded base; reviewed git history for the installer; read the pinned resolver and node-pty source; git diff --check passed; git diff --numstat origin/main reported 52 additions/5 deletions in the test and 4 additions/1 deletion in production, with no binary changes.