Skip to content

fix(coding-agent): allow the self-update tarball install on npm 12 - #1272

Open
smwbev wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
smwbev:fix/npm12-self-update-allow-remote
Open

fix(coding-agent): allow the self-update tarball install on npm 12#1272
smwbev wants to merge 2 commits into
PrimeIntellect-ai:mainfrom
smwbev:fix/npm12-self-update-allow-remote

Conversation

@smwbev

@smwbev smwbev commented Aug 12, 2026

Copy link
Copy Markdown

Problem

prime-agent update cannot update an npm-managed install on npm 12:

Updating prime-agent with npm --prefix /opt/homebrew install -g https://pub-728493de92a943e2a9b2d17b4719f318.r2.dev/releases/v0.7.2/prime-agent-0.7.2.tgz...
npm error code EALLOWREMOTE
npm error Fetching packages of type "remote" have been disabled
npm error Refusing to fetch "https://pub-728493de92a943e2a9b2d17b4719f318.r2.dev/releases/v0.7.2/prime-agent-0.7.2.tgz"
Error: npm --prefix /opt/homebrew install -g https://... exited with code 1

Reproduced on macOS (Apple Silicon), Node v26.5.0, npm 12.0.1, global npm install with prefix /opt/homebrew, updating 0.7.1 -> 0.7.2.

npm 12 defaults allow-remote to none. The self-update installs the release artifact by URL, which is a remote fetch, and the released package declares further tarball URLs (@earendil-works/pi-agent-core, pi-ai, pi-tui), which npm classifies as non-root — so root is not enough either, matching what @felipecsl measured in #741.

Change

  • SelfUpdateCommandStep carries an optional env, merged over the current environment when that step runs.
  • The npm branch of getSelfUpdateCommandForMethod sets npm_config_allow_remote=all on the install step, and only when isDirectPackageArtifactSpec(updateSpec) holds. Registry specs keep the stricter npm 12 default, and the follow-up uninstall step never gets the grant.
  • runSelfUpdate passes the step environment to spawn; steps without env keep inheriting process.env unchanged.

The grant is scoped to the one process that needs it. Nothing is written to the user's ~/.npmrc, which is the same approach #773 took for the installer.

isDirectPackageArtifactSpec rather than an npm version gate: the predicate already distinguishes the case that needs the config (a release artifact fetched by URL or path) from the case that must not get it (a registry spec), and it is the same condition that already decides the install/uninstall ordering. A version gate would grant allow-remote to registry updates as well on npm 12, which is strictly weaker; on npm < 12 the extra environment variable is ignored, so gating on the version buys nothing.

pnpm, yarn and bun install remote tarballs without an equivalent opt-in — pnpm's nearest setting, blockExoticSubdeps, is off by default and is not an env-scoped grant — so their branches are unchanged.

The step environment is rendered into display, so the "Updating ..." line and the copy-paste fallback describe the command that actually runs instead of one that fails without the assignment. The assignment is rendered in POSIX form; on Windows it reads as a description rather than a paste-ready line.

Verification

  • npm run check clean.
  • New regression test packages/coding-agent/test/suite/regressions/741-npm-self-update-allow-remote.test.ts; it fails on main and passes with this change. Existing test/config.test.ts expectations updated for the new field.
  • Real npm 12.0.1 check against the published 0.7.2 artifact, in a throwaway prefix:
$ npm --prefix "$tmp" install -g --dry-run https://pub-...r2.dev/releases/v0.7.2/prime-agent-0.7.2.tgz
npm error code EALLOWREMOTE

$ npm_config_allow_remote=all npm --prefix "$tmp" install -g --dry-run https://pub-...r2.dev/releases/v0.7.2/prime-agent-0.7.2.tgz
(resolves)

The spawn wiring itself is covered only by that manual run; the test asserts the command that runSelfUpdate receives.

Scope

Complementary to #773, which fixes the same npm 12 default on the install.sh side; there is no file overlap with it. Its author noted in #741 that the self-update path was deliberately left out, which is what this PR closes.

Two things stay out of scope:

  • npm 12 also blocks the postinstall that prepares uv and the IPython runtime unless allow-scripts covers it (reported by @felipecsl in install fails on npm 12+ due to allow-remote=none #741). That is a separate default with a different trade-off, so it is not silently granted here.
  • The deeper fix is publishing without transitive URL dependencies, which is a release-pipeline call for maintainers.

Refs #741 — deliberately not Fixes, since the issue also covers the installer surface handled in #773.

Note

Fix npm self-update to set npm_config_allow_remote=all for artifact installs

  • Adds an optional env field to the SelfUpdateCommandStep interface in config.ts, allowing per-step environment variable overrides merged over process.env at execution time.
  • In getSelfUpdateCommandForMethod, the npm install step now sets npm_config_allow_remote=all when the update spec is a direct artifact (e.g. file: or tarball URL); registry-based specs and the uninstall step are unaffected.
  • runSelfUpdate in package-manager-cli.ts applies step.env when spawning each step if present.
  • Display strings for steps with env vars are prefixed with NAME=value assignments.
  • Behavioral Change: npm artifact-based self-updates now spawn the install step with npm_config_allow_remote=all; all other update flows are unchanged.

Macroscope summarized 8c86051.

npm 12 defaults allow-remote to none, so `prime-agent update` fails with
EALLOWREMOTE when the release is installed from its tarball URL: the
download itself is a remote fetch, and the released package depends on
further tarball URLs, which npm treats as non-root, so "root" is not
enough either.

Carry an optional env on each self-update step and set
npm_config_allow_remote=all on the npm install step, but only when the
update spec is a direct package artifact (URL, file:, .tgz/.tar.gz).
Registry specs keep the stricter default, the user's npmrc is untouched,
and the grant lasts for the single install that needs it. pnpm, yarn and
bun have no equivalent gate, so those branches are unchanged.

Refs PrimeIntellect-ai#741
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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