[Bug] prime-agent update still fails under npm 12 — self-update needs the policy overrides the installer got in #1992 #2163
smwbev
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
v0.9.2 fixed the installer under npm 12 (#1992, from #1988) — that path works now, thanks. The self-update path (
prime-agent update) goes through different code and still fails with the same root cause: npm 12 defaultsallow-remotetonone, and the self-update command installs the release tarball by URL without any policy override.Environment
v0.9.4npm config get allow-remote→none(npm 12 default)Reproduce
npm install -g <release tarball URL>, or the stable installer).prime-agent update.EALLOWREMOTEand the update aborts.Workaround that confirms the cause:
Why #1992 does not cover this
#1992 patched
install.sh:prime_agent_npm_installadds--allow-remote=all --allow-scripts="$tarball_path"when npm is ≥ 12. Self-update never runs that shell script — it builds its own command in TypeScript.In
packages/coding-agent/src/config.ts@v0.9.4,getSelfUpdateCommandForMethod(the"npm"case) assembles:No env, no policy flags. When
updateSpecis the release tarball URL, npm 12 rejects it exactly as it rejected the installer before #1992.packages/coding-agent/src/package-manager-cli.ts@v0.9.4contains noallow-remoteornpm_configreference either.Suggested fix
The surrounding code already distinguishes the case that needs the override:
isDirectPackageArtifactSpecis true exactly whenupdateSpecis a direct artifact (the release tarball URL) rather than a registry spec. Scoping the policy to that predicate leaves registry installs untouched and mirrors how the installer scopes--allow-scriptsto the verified tarball rather than applying it globally.Concretely: give the self-update step an optional
env, and populate it only for direct-artifact specs withnpm_config_allow_remote=all— plusnpm_config_allow_scripts=<tarball>if you want self-update to reach parity with what the installer now does, since npm 12 gates lifecycle scripts separately.Patch
I have this implemented, with a regression suite covering the four spec shapes (direct artifact vs registry spec, with and without an explicit npm command): branch
fix/npm12-self-update-allow-remotein my fork (smwbev/prime-agent). It was PR #1272, closed with the August backlog cleanup — the branch is still there for review or cherry-pick.It predates the changelog-fragment process and the recent refactors, so it needs a rebase and a
.changes/fragment before it could land. Happy to redo it against currentmainif that is useful — or to leave it as reference if you would rather fix it your own way.All reactions