Skip to content

Default install to a user-level npm prefix (~/.local) - #2295

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-07_user-prefix-docs-default
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-07_user-prefix-docs-default

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Fixes #2294. Supersedes #2292 (that PR closed over a wrong closing link — Closes #2217 pointed at the unrelated hermes driver PR; this one links the issue correctly).

Summary

Make the documented default install land under a user-level prefix (~/.local) so Linux/macOS users never end up on a root-owned global prefix — the cohort behind the #1603/#2192 update retry-storms (a sudo-created root-owned install fails self-update at the swap stage and re-downloads the tarball every 3-min cycle, up to ~480 downloads/day/machine).

Approach (owner decision): one-shot --prefix, never touch the user's npm config. The documented command is npm install -g billion-context --prefix=~/.local — no npm config set prefix, ~/.npmrc is left untouched. Verified --prefix=~/.local tilde expansion works on the npm versions Node 22+/25 ship (npm 10.12 / 11.12: package lands in $HOME/.local/lib/node_modules, no literal ./~ directory). Since self-update is a tarball-swap over the running install dir (src/update.ts:597, it does not shell out to npm install -g), the user-owned prefix is all that matters — updates then work with zero flags.

Trade-off recorded: a one-shot flag must be repeated on any future npm reinstall of bili; the docs and the remediation hint both say so explicitly (README en/zh EACCES note, update.ts hint).

What changes (旧 → 新)

where before after
README.md Install one plain npm install -g billion-context block Linux/macOS: npm install -g billion-context --prefix=~/.local; bili lands in ~/.local/bin (PATH note only if missing); nvm/Homebrew-Node and Windows keep the plain install; EACCES troubleshooting → reinstall with --prefix=~/.local, "avoid sudo"
README.zh-CN.md 安装 same plain block zh mirror of the above (zh/en kept in sync)
website/blog/posts/2026-10-08_meet-bili.md / .zh.md bare install sentence adds the --prefix=~/.local parenthetical for non-nvm/Homebrew Linux/macOS (both are pre-launch drafts)
src/update.ts remediationHint (/not writable/ branch) "point npm at a user-writable prefix and reinstall (npm install -g …)" — generic platform-split: POSIX gets the concrete npm install -g billion-context --prefix="$HOME/.local" (+ PATH line + repeat-flag note); win32 gets "the default npm prefix (%APPDATA%\npm) is user-writable — repair that dir's ownership/permissions and reinstall"

The remediation hint is emitted on the #1603 backoff escalation log line only. String-only change — no download/extract/install/version-check logic touched, and no test asserts the old string. Flagging for the human reviewer per §5: src/update.ts changes normally route through the no-op-release protocol; this is a user-guidance string, not updater logic — owner decides whether staging is still wanted.

Windows compatibility

Windows keeps the plain install: npm's default prefix there (%APPDATA%\npm) is already user-writable, and ~/$HOME bash-isms don't apply — so the prefix flow is deliberately NOT advertised for Windows anywhere. The update.ts hint branches on process.platform.

Why this is the root-cause fix

The retry storm is produced at install time (docs teaching bare npm i -g onto a root-owned prefix → sudo → root-owned files). Preventing the root-owned prefix removes the producer; the concrete remediation string unblocks machines already stuck (#1603's "124× over 12 days" class). Downstream compatibility is already in place: client discovery searches ~/.local/lib/node_modules (src/agent/opencode-legacy.ts:113) and ~/.local/bin (src/pi-channel.ts:74, src/dsh-channel.ts:230, src/launcher.ts:3720).

Not changed (deliberately)

  • Hero one-liners (README.md:16, README.zh-CN.md:16, website/index.html chip) — correct for Windows/macOS/nvm; the Install section carries the prefix setup.
  • TECHNICAL-NOTES.md/.zh-CN.md install-lane tables — descriptive, not setup instructions.
  • CI workflow PR-comment snippets and reference/*.md internal recipes — dev/CI contexts with healthy prefixes.
  • Upgrade-banner hints (update-notes.ts, acp-status.ts, advisory.ts, web/client.ts) — nudges for already-running installs; the broken-prefix cohort hits the update.ts escalation hint instead.

Config surface

None — docs plus one log string; no config/env/flag additions. The user's own ~/.npmrc is explicitly NOT modified.

Pre-flight

  • Local: npm run typecheck ✅, npm run build ✅.
  • Full suite delegated to remote CI (owner instruction). First commit 7f14d85d is tree-identical to Default install to a user-level npm prefix (~/.local) #2292's CI-green head 4aa1233; second commit f66e32e7 is the owner-directed approach switch (docs strings + one log string).

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-07_user-prefix-docs-default (7f14d85)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2420-pr.2295.f2d5147

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2295.tgz
npm install -g package

Install instructions are refreshed on each push.

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.

docs: default install teaches bare npm install -g → root-owned prefix → sudo installs → #1603/#2192 update retry storms

1 participant