Skip to content

fix: npm 12 global updates no longer stop at the candidate guard - #108100

Merged
steipete merged 2 commits into
mainfrom
codex/followup-update-install-safety
Jul 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/followup-update-install-safety

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #107290
Related: #107239
Follow-up to #106994

What Problem This Solves

Fixes an issue where npm 12 users running a global OpenClaw update would safely stop before activation because npm 12 blocks dependency lifecycle scripts by default, leaving the candidate completion guard in place.

Why This Change Was Made

The updater now grants lifecycle permission only to the resolved OpenClaw candidate identity. Registry packages, npm aliases, local tarballs, local directories, and packed Git sources retain the identity and working directory npm uses for policy matching. Transitive dependency lifecycle scripts remain blocked on npm 12.

This is AI-assisted maintainer work. The implementation and npm contract were reviewed against npm's current official install documentation and npm 12 release guidance.

User Impact

npm 12 global updates can complete the candidate Node-engine check and clean staged swap instead of failing at the completion guard. npm 11.9 remains compatible. Incompatible candidates still fail before the live install changes.

Evidence

  • Focused tests: 56 passed across src/infra/update-global.test.ts and src/infra/package-update-steps.test.ts.
  • Source-blind packaged CLI validation: AWS Crabbox run run_91388c39c39d, lease cbx_6cdc1e217077, passed 4/4 scenarios: npm 12 update, npm 11.9 compatibility, UUID-redacted npm root, and incompatible-Node candidate preservation.
  • The packaged tarball integrity check passed during the same validation.
  • Docs MDX check passed: 732 files.
  • Fresh branch autoreview against current origin/main: no accepted or actionable findings.
  • git diff --check passed.

CHANGELOG.md is unchanged because release generation owns release notes.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S maintainer Maintainer-authored PR labels Jul 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3200ff4d9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (installCwd && path.isAbsolute(identity)) {
// npm resolves relative allow-scripts identities against its cwd. Relativize
// first so commas in ancestor directories do not split the policy value.
const relativeIdentity = path.relative(installCwd, identity) || ".";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve npm's file identity for packed tarballs

For packed Git/source updates, preparedSpec.installCwd is the pack directory, so this relativizes an absolute tarball path into ./openclaw-…tgz. npm 12's allowScripts matcher for file/directory keys compares the parsed key exactly against node.resolved (current @npmcli/arborist/lib/script-allowed.js matchFileOrDir), and Arborist records global tarball adds as file:/tmp/.../openclaw-…tgz; the relative key therefore does not match, npm silently skips OpenClaw's preinstall, and openclaw update main/GitHub-source updates still fail on the candidate guard. Keep the allow key in npm's resolved file:/... form, or verify the packed key against npm's matcher before using it.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/followup-update-install-safety branch 3 times, most recently from ead0e29 to 0720f5a Compare July 15, 2026 07:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0720f5a825

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

path.isAbsolute(normalized) ||
path.isAbsolute(unaliased)
? unaliased
: PRIMARY_PACKAGE_NAME;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the candidate package name for npm script approval

When the installed global package has a supported scoped/custom name such as @kevins8/openclaw, resolveGlobalInstallSpec builds @kevins8/openclaw@<tag>, but this new branch still approves only openclaw. npm's allow-scripts policy for registry deps matches the real package name (the npm matcher rejects entries where the trusted package name differs from the parsed allow key), so on npm 12 the scoped candidate's preinstall remains skipped, the completion guard stays in the staged package, and the update fails even though this path already carries the installed package name through callers like runGatewayUpdate.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/followup-update-install-safety branch from 0720f5a to b1210bb Compare July 15, 2026 07:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

"pack",
params.installSpec,
"--pack-destination",
packDir,
...NPM_PACK_QUIET_FLAGS,

P2 Badge Allow git before packing npm source updates

For main/GitHub update targets this npm pack <git spec> step runs before the new tarball install, but npm v12 defaults allow-git to none and the config docs note git fetches are blocked for other commands too. That means openclaw update main can fail during packing and never reach the added --allow-scripts install path; pass a narrow --allow-git=root/all for the explicit source spec here.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +990 to 992
resolveNpmInstallScriptsAllowFlag(spec, installCwd),
...(installPrefix ? ["--prefix", installPrefix] : []),
spec,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow npm 12 remote update specs

With an OPENCLAW_UPDATE_PACKAGE_SPEC=https://... override, this npm 12 command only opts into lifecycle scripts. The npm v12 changelog/config docs say allow-remote now defaults to none for user-supplied tarball URL dependencies, so npm i -g https://... fails before OpenClaw's preinstall can run; add the matching --allow-remote=root/all opt-in for explicit remote root specs.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 0be803e into main Jul 15, 2026
107 checks passed
@steipete
steipete deleted the codex/followup-update-install-safety branch July 15, 2026 08:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

SunMe1977 pushed a commit to SunMe1977/openclaw that referenced this pull request Jul 15, 2026
…nclaw#108100)

* fix(update): approve candidate lifecycle on npm 12

* test(update): align npm lifecycle argv expectations
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
…nclaw#108100)

* fix(update): approve candidate lifecycle on npm 12

* test(update): align npm lifecycle argv expectations
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…nclaw#108100)

* fix(update): approve candidate lifecycle on npm 12

* test(update): align npm lifecycle argv expectations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Auto-updater applies a version requiring a newer Node with no engine check, no warning, and no user prompt — leaves the install broken

1 participant