Skip to content

fix(host): keep fnm's stable Node link in machine services - #6774

Merged
ymichael merged 2 commits into
mainfrom
slopcop/issue-6773
Nov 2, 2026
Merged

ymichael merged 2 commits into
mainfrom
slopcop/issue-6773

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

The POSIX machine installer writes command -v node into the systemd unit, the launch agent, and the ~/.local/bin/bb shim. Under fnm that path goes through a per-shell fnm_multishells/<session> link. On Linux the link lives in $XDG_RUNTIME_DIR (/run/user/<uid>), which is cleared on reboot, so the unit fails with 203/EXEC and the machine stays offline.

The first version of this PR used process.execPath, which resolves every link. That fixes fnm but regresses stable PATH links: Homebrew's /opt/homebrew/bin/node becomes /opt/homebrew/Cellar/node/<version>/bin/node, which the next brew upgrade deletes. mise, Volta and asdf shims become version folders the same way.

Fixes #6773

What changed

  • apps/server/src/assets/install-machine.sh: keeps the PATH lookup. When it is …/fnm_multishells/<session>/bin/node, the installer reads that session link once and saves its target. Normally that is fnm's aliases/default, so the service follows fnm default; after fnm use X it is that version's install folder. Any other path is saved unchanged. If readlink fails, the installer behaves as before.
  • apps/server/test/app/install-machine-script.test.ts: new test that builds fnm's layout (version install, aliases/default, per-shell link first on PATH) and checks that the systemd unit and the bb shim use aliases/default/bin/node. The existing systemd test now checks that an ordinary PATH link (the Homebrew shape) is saved unchanged. The stub systemctl it shared with the new test is now a helper.
  • No protocol, CLI or docs change. Existing installs pick this up only when the install command is re-run.

How you verified

  • Before the fix, on main at 6e77fce, the new test fails and the generated unit shows the reporter's shape: ExecStart="…/fnm_multishells/476_1793101823158/bin/node" …. After the fix it passes.
  • pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts: 54/54 pass. pnpm exec turbo run typecheck --filter=@bb/server passes, as do sh -n and oxfmt --check.
  • Checked against real fnm 1.39.0 on macOS in an isolated FNM_DIR (fnm install 24, fnm default 24). The per-shell link points to aliases/default, and the installer's new code returns …/aliases/default/bin/node. That path still runs (v24.22.2) after the per-shell link is deleted.
  • Not verified: a real Linux/WSL reboot under systemd, or Windows (install-machine-windows.mjs uses process.execPath and is unchanged).

AGENT GENERATED

🤖 Generated with Claude Code

process.execPath resolves every link, so Homebrew's
/opt/homebrew/bin/node became a Cellar version directory that the next
`brew upgrade` deletes, and mise/Volta/asdf shims became version
directories the same way. Keep the PATH lookup and resolve only fnm's
per-shell fnm_multishells link, one level, to aliases/default or the
version chosen with `fnm use`.

Fixes #6773

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title fix(host): persist resolved Node executable for machine services fix(host): keep fnm's stable Node link in machine services Nov 2, 2026
@ymichael
ymichael merged commit 21ff1a4 into main Nov 2, 2026
31 checks passed
@ymichael
ymichael deleted the slopcop/issue-6773 branch November 2, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants