Skip to content

fix(bootstrap): install pi globally so pi update self-updates and persists - #111

Merged
lucy-wolfe merged 2 commits into
mainfrom
fix/pi-global-install-self-update
Aug 20, 2026
Merged

lucy-wolfe merged 2 commits into
mainfrom
fix/pi-global-install-self-update

Conversation

@lucy-wolfe

Copy link
Copy Markdown
Contributor

Why

On an ATA box, pi update fails:

error: pi cannot self-update this installation.
This installation is not managed by a global npm install.
Location of pi executable: /root/workspace/node_modules/.bin/pi

bootstrap.sh installs pi as a bun workspace devDependency and symlinks /usr/local/bin/pi to node_modules/.bin/pi. pi's self-updater refuses that layout — verified against pi 0.80.3's own dist/config.js: isManagedByGlobalPackageManager requires the package under npm root -g or a <prefix>/lib/node_modules shape, which a bun workspace devDep is neither.

Fix

Install the pinned pi globally so the updater accepts it, on ATA's persistent home so the update sticks:

  • After bun install, install_pi_global() reads the exact pin from package.json devDependencies and runs npm install -g @earendil-works/pi-coding-agent@<ver> (prefix /root/.npm-global, which is on /dev/vda — the persistent per-box disk, and first on PATH in both the agent and login shells).
  • Repoints /usr/local/bin/pi at the global bin, with a fallback if the global install didn't land.
  • After this, pi update writes to the persistent prefix (pi's update command is prefix-explicit) and survives reboot. The ata bootstrap runs once per box (workspace on vda), so a reboot never re-runs it to downgrade an updated pi back to the pin.

Verified against pi's own code: the global layout is ACCEPTED (getSelfUpdateCommand returns a real npm command); the bun devDep is REFUSED, exactly as reported.

Consistency + safety (from review)

  • Fallback path fixed: if npm i -g hiccups, the fallback now symlinks the devDep into /root/.npm-global/bin (PATH-first in every shell) rather than relying on node_modules/.bin. Without this, the agent shell would run the baked pi (0.80.10) while a login shell ran the devDep 0.80.3 — which pi split between shells. Now both the success and fallback paths put the same 0.80.3 pi first on PATH everywhere.
  • Non-fatal: a registry hiccup never blocks the harness from starting.
  • Idempotent: a re-run skips when the pinned version is already installed. Version read is guarded with a numeric case (rejects an empty read, node -p's literal "undefined", and a stray range).
  • Kept the bun devDeps (typecheck + PiSettingsContract.test import them) — the global install is additive for the runtime CLI.
  • Corrected a stale note (pin is 0.80.3, not 0.79.8) and documented the intended drift: a user's pi update moves the runtime pi ahead of the 0.80.3-pinned extensions — that's the shipped feature.

Verification

sh -n/bash -n clean; shellcheck no new warnings. Eligibility proven by running pi's own getSelfUpdateCommand against the global layout (ACCEPTED) and the devDep layout (REFUSED). PATH order, NPM_CONFIG_PREFIX, and vda persistence were measured on a live box running the same platform image.

Not verified here: a full end-to-end ATA boot and an actual pi update mutation (eligibility verified via pi's shipped code, not a live update run).

root and others added 2 commits August 20, 2026 13:12
…f-updates

The runtime pi was a bun-workspace devDep symlinked to /usr/local/bin, which
pi's self-updater refuses: getSelfUpdateCommand -> isManagedByGlobalPackageManager
only accepts a package dir under `npm root -g` or the `<prefix>/lib/node_modules`
shape, and `<ws>/node_modules/...` is neither. Install pi globally to the
persistent /root/.npm-global prefix (version pinned from package.json's devDep so
they never diverge), landing at /root/.npm-global/lib/node_modules/... — the exact
layout the updater accepts. /root/.npm-global/bin is first on PATH in every shell,
so this global pi is the runtime pi; /usr/local/bin/pi is repointed to it.

Idempotent (skips when the pinned version is already global) and non-fatal (a
registry hiccup falls back to the node_modules/.bin pi, which still boots). The
bun devDeps stay: typecheck + the pinned-type tests need them; the global install
is additive for the runtime CLI only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n note + guards

Fold in review fixes on the pi global-install self-update change:

- Fallback (global install absent) now symlinks the bun devDep into the
  writable, PATH-first npm-global prefix ($NPM_PREFIX/bin/pi) instead of
  pointing at $PWD/node_modules/.bin/pi. On ATA the agent PATH has no
  node_modules/.bin and a baked pi at /opt/zipbox/harnesses/defaults/bin
  outranks /usr/local/bin, so the old fallback split `which pi` between the
  agent (baked) and login shells (devDep). Symlinking into the prefix makes
  the SAME 0.80.3 pi win first on PATH in every shell. Non-fatal.
- Correct the do-not-`pi update` NOTE: pin is 0.80.3 (was stale 0.79.8), and
  document that a user's own `pi update` intentionally moves the runtime pi
  ahead of the pinned devDep/extensions — the shipped feature, not a bug.
- Guard the version read with a numeric `case [0-9]*` so a missing devDep key
  (node -p prints "undefined") or a stray range never becomes `npm i -g @…@undefined`.
- Hardcode the NPM_PREFIX fallback to /root/.npm-global; $HOME/.npm-global is
  wrong on ATA where HOME=/root/workspace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lucy-wolfe
lucy-wolfe merged commit 3215b4b into main Aug 20, 2026
1 check failed
@lucy-wolfe
lucy-wolfe deleted the fix/pi-global-install-self-update branch August 20, 2026 13:31
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.

1 participant