ensure the bun symlink on every run, not only after installing it
The link was made as part of install_bun, so a machine that already had bun never got one. That is this machine: bun 1.3.14 in ~/.bun/bin, no /usr/local/bin/bun, and `bun` resolving to nothing at all for root. Nothing has broken yet only because `pm2 startup` has never been run here — the moment boot persistence is enabled, all twenty ecosystem apps that say `script: 'bun'` fail at boot and work perfectly when started by hand. ensure_bun_symlink now runs whether or not this script did the install, and says which of the three things happened: made it, found it already correct, or could not find bun to link. The last records an error, since a missing link is a reboot-shaped failure rather than a cosmetic one. Safe across upgrades, which was the question: a symlink resolves by path, not by inode, and `bun upgrade` replaces the file at $BUN_INSTALL/bin/bun rather than moving it. Demonstrated by replacing a target with a new file — new inode, link still resolves. It breaks only if the home directory goes, which breaks bun anyway. Also fixed the status line, which reported "not installed" on a machine with bun in the user's home: it asked root's PATH, which is exactly what has no bun before the link exists. bun_version now asks whichever copy is there. This run created the link on this machine — /usr/local/bin/bun -> the account's copy, and root can now run bun. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1967,7 +1967,7 @@ if ! skip; then
|
||||
echo " node ${NODE_NOW:+v$NODE_NOW }${NODE_NOW:+-> }LTS $(node_lts_label)"
|
||||
echo " pm2 is a Node application, and officer-pty compiles node-pty"
|
||||
echo " against whatever Node is installed — there is no Linux prebuild."
|
||||
echo " bun $(bun_installed && bun --version 2>/dev/null || echo 'not installed')"
|
||||
echo " bun $(bun_installed && bun_version || echo 'not installed')"
|
||||
echo " the platform itself, and nineteen of the twenty pm2 apps."
|
||||
echo " pm2 $(pm2_installed && echo installed || echo 'not installed')"
|
||||
echo " supervises all of them, and the ecosystem files are written for it."
|
||||
@@ -1996,18 +1996,31 @@ if ! skip; then
|
||||
|
||||
# ── bun ──
|
||||
if bun_installed; then
|
||||
ok "bun $(bun --version 2>/dev/null) already installed"
|
||||
ok "bun $(bun_version) already installed"
|
||||
else
|
||||
info " installing bun..."
|
||||
if install_bun && bun_installed; then
|
||||
ok "bun $(bun --version), symlinked to /usr/local/bin/bun"
|
||||
SUMMARY+=("Bun: $(bun --version)")
|
||||
ok "bun $(bun_version)"
|
||||
SUMMARY+=("Bun: $(bun_version)")
|
||||
else
|
||||
warn "the bun install did not complete"
|
||||
ERRORS+=("Bun: install failed")
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensured every run, not only after an install. A machine that already had bun
|
||||
# would otherwise never get the link, and the failure only shows up at the next
|
||||
# reboot.
|
||||
if ensure_bun_symlink; then
|
||||
ok "bun symlinked to /usr/local/bin/bun — pm2 at boot has no ~/.bun on PATH"
|
||||
SUMMARY+=("Bun: symlinked system-wide")
|
||||
elif [[ -x /usr/local/bin/bun ]]; then
|
||||
echo " /usr/local/bin/bun already points at it"
|
||||
else
|
||||
warn "bun is not at ${USER_HOME}/.bun/bin/bun — cannot link it system-wide"
|
||||
ERRORS+=("Bun: no system-wide symlink; pm2 apps will fail at boot")
|
||||
fi
|
||||
|
||||
# ── pm2 ──
|
||||
if pm2_installed; then
|
||||
ok "pm2 $(pm2 -v 2>/dev/null | tail -1) already installed"
|
||||
|
||||
Reference in New Issue
Block a user