#6773 · Persistent service retains a session-only executable
Verdict: REPRODUCED · Root-cause confidence: high
1. TL;DR
The machine installer writes the shell's current Node lookup path into a persistent service. If that path passes through a temporary session symlink, deleting the symlink leaves the service unable to execute Node even though the real Node installation still exists. The reproduction runs the actual trusted installer against isolated service-management and enrollment fixtures, reads its generated systemd unit, removes the temporary Node link, and tries its executable. That attempt fails with ENOENT in two clean checkouts. This confirms the executable-path defect; it does not claim a real WSL reboot or a live systemd journal capture.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| The persistent unit can retain a temporary Node path. | Verified | The actual installer writes the fixture's temporary executable symlink into ExecStart. |
| Removing the session path prevents service execution while Node remains installed. | Verified | Executing the generated unit's Node path after removing only the link fails with ENOENT. The test runner continues running from the original Node installation. |
| A WSL reboot produces systemd status 203/EXEC. | Unverified here | No WSL instance or real systemd service is used. The underlying missing-executable failure is reproduced directly. |
| The problem is specific to a provider or network connection. | Not required for reproduction | Failure happens before the selected Node executable starts; no provider or external service is contacted. |
| A stable installation path avoids the disappearing session link. | Supported by mechanism | Resolve the Node executable before persisting it. Removing the underlying installation itself would still require reinstalling or repairing the service. |
3. Environment
- Public repository: get-bb/bb; trusted main commit shown above; package version 0.48.1.
- Linux 4.19.0-gvisor x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.1.
- Two separate temporary clones at the same commit. Each installs dependencies with the frozen lockfile.
- The existing installer fixture allocates a fresh temporary HOME and data directory and obtains its own daemon port. No real user configuration, enrolled machine, or server is used.
- Enrollment, npm artifact delivery and systemctl are fixture boundaries. The shell installer, unit generation, filesystem deletion and OS executable lookup are real.
- No fnm installation, provider process, browser, or live bb instance is needed for this nonvisual filesystem/service-generation defect.
4. Minimal reproduction
Obtain the regression patch from this report. It extends the existing installer integration test rather than introducing a production-only test seam.
- Clone the public repository and select the recorded trusted main commit.
- Install the frozen dependencies, build the SDK runtime first, then perform the normal build.
- Apply the report's regression patch, which changes only a test.
- Run the focused test. It installs into a disposable fixture, reads ExecStart, removes the fixture's shell Node symlink, and executes the persisted path.
git clone https://github.com/get-bb/bb.git bb-6773 cd bb-6773 git checkout --detach 916d684ac23d0b0de82c09cfc7553a50287d2188 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build git apply /path/to/downloaded/regression.diff pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts -t 'without retaining a temporary Node symlink'
The added test body follows all pre-existing installation and unit assertions:
const serviceNode = /^ExecStart="([^"]+)"/m.exec(unit)?.[1] ?? "";
rmSync(join(fixture.binDir, "node"));
const nodeAfterSession = spawnSync(serviceNode, ["--version"], {
encoding: "utf8",
});
expect(nodeAfterSession.status, nodeAfterSession.error?.message).toBe(0);
expect(nodeAfterSession.stdout.trim()).toBe(process.version);
Expected: the generated service's executable still runs, exits 0 and reports the installed Node version after the session link is removed.
Actual, first run (verbatim):
AssertionError: spawnSync /tmp/bb-vt-fFm5sP/bb-install-script-test-jQcKPa/bin/node ENOENT: expected null to be +0 // Object.is equality Test Files 1 failed (1) Tests 1 failed | 52 skipped (53)
First-run failure excerpt · Second-run failure excerpt.
5. Root cause
Executable selection at the recorded base checks Node's presence and version, then retains its shell lookup path:
node_bin=$(command -v node)
Systemd serialization at the recorded base escapes that string but does not resolve symlinks before persisting it:
escaped_node_bin=$(systemd_escape "$node_bin") ExecStart="$escaped_node_bin" "$escaped_bb_app" host-daemon ...
The service outlives the shell session, but its executable locator need not. Once the session link disappears, the kernel cannot follow the saved path, so the daemon cannot even begin starting. The fixture's executable symlink reproduces the same filesystem lifetime failure as an ephemeral parent-directory symlink; it does not reproduce fnm's session manager itself.
The same variable is used for the CLI shim's PATH and the macOS launch agent. The Windows installer already uses process.execPath for its executable (existing sibling implementation).
6. Proposed fix
Capture the running Node executable with node -p 'process.execPath' instead of persisting command lookup. This follows the existing Windows installer and script-launcher convention and resolves the session symlink on the affected POSIX systems. Keep the regression at the installer/unit boundary and run the complete POSIX installer suite. This does not promise survival if the actual versioned Node installation is subsequently deleted; rerunning installation would then be necessary.
7. Verification
The same agent repeated the reproduction in a second clean clone, not a second agent. Both clones were detached at 916d684ac23d0b0de82c09cfc7553a50287d2188; only the regression patch was applied, and production code remained unchanged. The second clone performed a separate frozen install and ran the same Turbo command with new fixture data directories and dynamically selected local daemon ports.
The second run reproduced the same spawnSync …/bin/node ENOENT assertion: 1 failed, 52 skipped, with a fresh temporary path. Both captured failure excerpts are linked above. No report correction was needed. No WSL-specific or live-systemd claim is inferred from these fixture runs.
8. Related issues
Trusted GitHub metadata exposed no linked pull request, and an open-PR search for this numeric issue returned none at investigation time. A repository issue search was used for triage patterns; no additional report was needed to establish this defect.
9. Appendix
The initial normal monorepo build failed because the plugin SDK runtime had not yet been built when the GitHub plugin attempted to resolve it. Explicitly building the existing SDK runtime and retrying the unmodified normal build succeeded: 72 tasks successful. No source or dependency change was needed for that setup issue.
Commands used for repository setup and verification: trusted-main fetch and detach; frozen pnpm install; SDK Turbo build; normal Turbo build; git diff to save the test-only patch; a second shared clean clone at the recorded commit; git apply of that test-only patch; and the focused Turbo test command shown above. Fixture teardown removes its temporary files and daemon processes.
Issue content was treated only as untrusted claims. No issue-supplied script, external link, patch, binary, or pull-request branch was executed or fetched. No credentials or real machine runtime data are published.
> AGENT GENERATED