Skip to content

fix(install): systemd service uses ephemeral fnm Node.js path and fails after reboot #6773

Closed

Description

@alexengrig

Summary

When installing a bb host daemon on Linux with Node.js managed by fnm, the installer saves a temporary fnm_multishells executable path in the systemd service's ExecStart.

The installation initially works, but after restarting WSL the temporary path disappears. The service fails repeatedly with status=203/EXEC, leaving the machine Offline in bb instead of reconnecting automatically.

Versions and environment

  • bb: 0.48.1
  • Installation method: Machine enrollment via the server-provided install.sh
  • Host OS: Windows with WSL2
  • Linux: Ubuntu 26.04.1 LTS (Resolute Raccoon)
  • Node.js: v24.22.1
  • Node version manager: fnm 1.39.0
  • Default Node.js version: fnm default 24
  • Init system: systemd (PID 1)
  • Service: Enabled systemd user unit (bb-host-daemon-*.service)
  • User lingering: Enabled via loginctl enable-linger
  • Host daemon port: 38888
  • Setup: Remote WSL machine connected to a bb server
  • Observed: October 31, 2026
  • Latest-release verification: Reproduced with bb 0.48.1; not independently verified against the latest release or main

No provider-specific steps are involved: the failure occurs before the host daemon starts.

Steps to reproduce

  1. Use a Linux system with systemd and Node.js installed through fnm (in my case, Ubuntu on WSL2).

  2. Select the default Node.js version:

    fnm install 24
    fnm default 24
  3. Verify that Node.js resolves through a temporary fnm path:

    command -v node
    # /run/user/1000/fnm_multishells/<session>/bin/node
  4. Install and enroll a bb host machine using the server-provided install.sh command.

  5. Inspect the generated systemd service:

    systemctl --user cat bb-host-daemon-<machine>.service

    Observe that ExecStart contains the temporary /run/user/1000/fnm_multishells/.../bin/node path.

  6. Restart WSL using wsl --shutdown from Windows PowerShell, then start the distribution again. Alternatively, reboot Windows and start WSL.

  7. Inspect the host daemon service:

    systemctl --user status bb-host-daemon-<machine>.service
  8. Observe that the service fails with status=203/EXEC because the previously saved Node.js path no longer exists.

The machine remains Offline in bb.

Expected vs actual

**Expected behavior**

The installer should generate a persistent systemd service using a Node.js executable path that remains valid across restarts.

After WSL restarts, the host daemon should start and reconnect automatically when the bb server is reachable.

**Actual behavior**

The generated service contains a temporary fnm executable path:


ExecStart="/run/user/1000/fnm_multishells/476_1793101823158/bin/node" "/home/<user>/.bb-machines/<server>/npm/bin/bb-app" host-daemon --auto-update ...


After restarting WSL, systemd repeatedly fails to execute Node.js.

Actual journal output:


Unable to locate executable '/run/user/1000/fnm_multishells/476_1793101823158/bin/node': No such file or directory

Failed at step EXEC spawning /run/user/1000/fnm_multishells/476_1793101823158/bin/node: No such file or directory

Main process exited, code=exited, status=203/EXEC


Service status:


Active: activating (auto-restart) (Result: exit-code)

Result=exit-code
NRestarts=71
ExecMainStatus=203


Node.js is still installed and works correctly in an interactive shell:


$ node --version
v24.22.1

$ which node
/run/user/1000/fnm_multishells/500_1793464947596/bin/node


The current shell has a new fnm session path, but systemd continues using the old path saved during installation.

Evidence

Suspected root cause confirmed by the generated systemd unit and journal output

The installer captures the current Node.js executable path using command -v node:

[install-machine.sh, lines 393–410](

if ! command -v node >/dev/null 2>&1; then
fail_step "bb-app requires Node.js 22.19 or newer (22.19, 24, and 26 are tested), but node is not on PATH."
exit 1
fi
node_version=$(node -p 'process.versions.node')
# Open-ended floor rather than an allow-list of tested majors: Pi only requires
# >=22.19, and a closed list turns every future release line into a hard
# install failure on the day it ships.
node_supported=$(node -e '
const [major, minor] = process.versions.node.split(".").map(Number);
const supported = major > 22 || (major === 22 && minor >= 19);
process.exit(supported ? 0 : 1);
' && echo yes || echo no)
if [ "$node_supported" != yes ]; then
fail_step "Node.js $node_version is too old; bb-app requires Node.js 22.19 or newer (22.19, 24, and 26 are tested)."
exit 1
fi
node_bin=$(command -v node)
)

node_bin=$(command -v node)

The captured path is then written directly into the persistent systemd service:

[install-machine.sh, lines 1155–1165](

cat >"$service_file" <<EOF
[Unit]
Description=bb host daemon for $server_host
After=network-online.target
Wants=network-online.target
[Service]
ExecStart="$escaped_node_bin" "$escaped_bb_app" host-daemon --auto-update --host-daemon-port "$host_daemon_port" --server-url "$escaped_server"
Environment="BB_APP_NPM_PREFIX=$escaped_bb_app_npm_prefix"
Environment="BB_DATA_DIR=$escaped_data_dir"
Restart=always
)

ExecStart="$escaped_node_bin" "$escaped_bb_app" host-daemon ...

With fnm, command -v node can return a session-specific path under /run/user/1000/fnm_multishells/. This path is not guaranteed to exist after WSL restarts.

Related implementation

Interestingly, bb already accounts for changing fnm multishell paths when comparing shell environments:

  • [runtime-manager.ts](
    const FNM_MULTISHELL_PATH_ENTRY = /([\\/]fnm_multishells[\\/])[^\\/]+/;
    function comparableShellEnvValue(key: string, value: string): string {
    if (key !== "PATH") return value;
    return value
    .split(path.delimiter)
    .map((entry) => entry.replace(FNM_MULTISHELL_PATH_ENTRY, "$1*"))
    .join(path.delimiter);
    }
    function shellEnvEquals(
    left: NonNullable<AgentRuntimeOptions["shellEnv"]>,
    )
  • [runtime-manager.test.ts](
    it("keeps runtimes when only fnm multishell PATH entries change", async () => {
    const dataDir = await makeTempDir("bb-provider-maintenance-fnm-");
    const runtime = createFakeRuntime();
    const createRuntime = vi.fn(() => runtime);
    const manager = new RuntimeManager({
    createRuntime,
    shellEnv: {
    PATH: "/Users/me/Library/Caches/fnm_multishells/123_1/bin:/usr/bin",
    },
    });
    await manager.ensureProviderMaintenanceRuntime({ dataDir });
    await manager.replaceBaseShellEnv({
    PATH: "/Users/me/Library/Caches/fnm_multishells/456_2/bin:/usr/bin",
    });
    expect(runtime.shutdown).not.toHaveBeenCalled();
    await expect(
    manager.ensureProviderMaintenanceRuntime({ dataDir }),
    ).resolves.toBe(runtime);
    expect(createRuntime).toHaveBeenCalledOnce();
    )

However, this handling does not apply to systemd service generation.

Suggested fix

Resolve the temporary executable path to a persistent location before writing the service, for example:

node_bin=$(node -p 'require("node:fs").realpathSync(process.execPath)')

Alternatively, support a stable fnm alias when available:

~/.local/share/fnm/aliases/default/bin/node

The first approach would survive a reboot but would require updating the service if that specific Node.js installation is removed.

A regression test should verify that installing with an fnm_multishells PATH entry does not generate a service depending on the temporary directory.

What you ruled out

Investigation prepared with AI assistance from actual systemd logs and bb source code.

Suggested priority and effort (optional)

Medium priority, likely low effort — affects Linux users with Node.js managed by fnm, preventing automatic host reconnection after reboot. A manual systemd override is available as a workaround. No known data loss.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • 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.

Activity

  1. added theissue type on Oct 31, 2026
  2. added
    host
    confirmed-repro
    on Oct 31, 2026
  3. bb-slop-cop commented on Oct 31, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Low; labels host, confirmed-repro. All were missing and are now applied.
    • Reproduction report: REPRODUCED, with high root-cause confidence; repeated in two clean trusted-main checkouts.
    • Root cause: The POSIX installer saves the shell's temporary Node lookup path in systemd ExecStart; removing that session symlink leaves the persisted executable path unusable (ENOENT).
    • Fix: Ready PR fix(host): keep fnm's stable Node link in machine services #6774 captures the running executable's resolved path. Two files, 11 changed lines. The regression fails before the fix; all 53 installer tests, server typecheck/build, formatting, shell syntax, and diff checks pass afterward.
    • Scope: Actual installer with isolated service/enrollment fixtures; no real WSL reboot or live systemd validation. PR is not merged.

    AGENT GENERATED

  4. added a commit that references this issue on Nov 2, 2026
    51cbdbe
  5. added a commit that references this issue on Nov 2, 2026
    21ff1a4
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-reprohost

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions