Skip to content

fix(update): avoid per-Node npm prefixes during self-update - #93650

Merged
vincentkoc merged 1 commit into
mainfrom
clownfish/gitcrawl-159-autonomous-terminal-gap
Jun 16, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
clownfish/gitcrawl-159-autonomous-terminal-gap

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Fixes #80387 by repairing the existing contributor PR #80386 from @yaanfpv.

This keeps the same narrow behavior: OpenClaw should still detect npm ownership for the current global install, but the reinstall command should avoid Homebrew Cellar and version-manager per-Node npm prefixes so a later Node major upgrade does not delete the command shim target. Stable npm global prefixes should continue to resolve as before.

Repair checklist for Clownfish:

  • Rebase or refresh fix(update): Keep Openclaw alive across brew upgrade and other Node version bumps #80386 onto current main c45c87a.
  • Address the ClawSweeper merge-prep finding by removing/moving the release-owned CHANGELOG.md edit if still present.
  • Keep regression coverage for Homebrew Cellar, nvm, asdf, volta, fnm, and n layouts, including ownership detection staying npm while install argv falls back to PATH npm.
  • Run pnpm -s vitest run src/infra/update-global.test.ts and pnpm check:changed.
  • Run Codex /review and address every finding before merge preflight.

Clownfish 🐠 replacement reef notes:

fish notes: model gpt-5.5, reasoning medium; reviewed against 82c8b7c.

@vincentkoc vincentkoc added the clownfish Tracked by Clownfish automation label Jun 16, 2026
@vincentkoc
vincentkoc merged commit df8ceb5 into main Jun 16, 2026
24 of 27 checks passed
@vincentkoc
vincentkoc deleted the clownfish/gitcrawl-159-autonomous-terminal-gap branch June 16, 2026 13:54
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jun 16, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 17, 2026
…#93650)

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
Co-authored-by: Soham Patankar <[email protected]>
steipete pushed a commit to buddyh/openclaw that referenced this pull request Jul 7, 2026
Package self-updates resolved their install target from `npm root -g`
even when the running install's package root was already known. In an
environment where PATH's npm does not belong to the running install's
Node tree (a launchd/systemd service PATH, or mixed Homebrew + nvm
setups), the probe points at a different global root — or derives a
brand-new one — so the update installs there, reports success, and
leaves the running install stale.

Observed in the wild: a gateway-managed `openclaw update --yes` on
2026.5.28 ran nvm's npm under Homebrew's node, npm derived its default
prefix from the realpathed execPath, and the update installed a full
copy into /opt/homebrew/Cellar/node/26.3.1/lib/node_modules/openclaw
("before": null — a tree that had never existed) while the running nvm
install stayed on the old version until a manual shell update.

resolveGlobalInstallTarget now prefers the package root's own global
root for npm targets; the `npm root -g` probe only decides the target
when no package root is known, and an ephemeral per-Node probe result
(Homebrew Cellar, nvm/n/asdf/volta version dirs — the same set
openclaw#93650 filters npm commands against) is never adopted.
steipete added a commit that referenced this pull request Jul 7, 2026
…101228)

* fix(update): keep self-updates on the running install's global root

Package self-updates resolved their install target from `npm root -g`
even when the running install's package root was already known. In an
environment where PATH's npm does not belong to the running install's
Node tree (a launchd/systemd service PATH, or mixed Homebrew + nvm
setups), the probe points at a different global root — or derives a
brand-new one — so the update installs there, reports success, and
leaves the running install stale.

Observed in the wild: a gateway-managed `openclaw update --yes` on
2026.5.28 ran nvm's npm under Homebrew's node, npm derived its default
prefix from the realpathed execPath, and the update installed a full
copy into /opt/homebrew/Cellar/node/26.3.1/lib/node_modules/openclaw
("before": null — a tree that had never existed) while the running nvm
install stayed on the old version until a manual shell update.

resolveGlobalInstallTarget now prefers the package root's own global
root for npm targets; the `npm root -g` probe only decides the target
when no package root is known, and an ephemeral per-Node probe result
(Homebrew Cellar, nvm/n/asdf/volta version dirs — the same set
#93650 filters npm commands against) is never adopted.

* fix(update): infer global roots for scoped package roots

The running-root fallback missed scoped installs because
inferGlobalRootFromPackageRoot only accepted an immediate node_modules
parent. Hop over an @scope segment so node_modules/@scope/name resolves
to the same global root. Regression test: scoped package root with an
ephemeral probe now falls back to the running root.

* fix(update): scope running-root selection

* docs(changelog): note npm self-update root fix

* chore(changelog): defer release note

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…penclaw#101228)

* fix(update): keep self-updates on the running install's global root

Package self-updates resolved their install target from `npm root -g`
even when the running install's package root was already known. In an
environment where PATH's npm does not belong to the running install's
Node tree (a launchd/systemd service PATH, or mixed Homebrew + nvm
setups), the probe points at a different global root — or derives a
brand-new one — so the update installs there, reports success, and
leaves the running install stale.

Observed in the wild: a gateway-managed `openclaw update --yes` on
2026.5.28 ran nvm's npm under Homebrew's node, npm derived its default
prefix from the realpathed execPath, and the update installed a full
copy into /opt/homebrew/Cellar/node/26.3.1/lib/node_modules/openclaw
("before": null — a tree that had never existed) while the running nvm
install stayed on the old version until a manual shell update.

resolveGlobalInstallTarget now prefers the package root's own global
root for npm targets; the `npm root -g` probe only decides the target
when no package root is known, and an ephemeral per-Node probe result
(Homebrew Cellar, nvm/n/asdf/volta version dirs — the same set
openclaw#93650 filters npm commands against) is never adopted.

* fix(update): infer global roots for scoped package roots

The running-root fallback missed scoped installs because
inferGlobalRootFromPackageRoot only accepted an immediate node_modules
parent. Hop over an @scope segment so node_modules/@scope/name resolves
to the same global root. Regression test: scoped package root with an
ephemeral probe now falls back to the running root.

* fix(update): scope running-root selection

* docs(changelog): note npm self-update root fix

* chore(changelog): defer release note

---------

Co-authored-by: Peter Steinberger <[email protected]>
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
…penclaw#101228)

* fix(update): keep self-updates on the running install's global root

Package self-updates resolved their install target from `npm root -g`
even when the running install's package root was already known. In an
environment where PATH's npm does not belong to the running install's
Node tree (a launchd/systemd service PATH, or mixed Homebrew + nvm
setups), the probe points at a different global root — or derives a
brand-new one — so the update installs there, reports success, and
leaves the running install stale.

Observed in the wild: a gateway-managed `openclaw update --yes` on
2026.5.28 ran nvm's npm under Homebrew's node, npm derived its default
prefix from the realpathed execPath, and the update installed a full
copy into /opt/homebrew/Cellar/node/26.3.1/lib/node_modules/openclaw
("before": null — a tree that had never existed) while the running nvm
install stayed on the old version until a manual shell update.

resolveGlobalInstallTarget now prefers the package root's own global
root for npm targets; the `npm root -g` probe only decides the target
when no package root is known, and an ephemeral per-Node probe result
(Homebrew Cellar, nvm/n/asdf/volta version dirs — the same set
openclaw#93650 filters npm commands against) is never adopted.

* fix(update): infer global roots for scoped package roots

The running-root fallback missed scoped installs because
inferGlobalRootFromPackageRoot only accepted an immediate node_modules
parent. Hop over an @scope segment so node_modules/@scope/name resolves
to the same global root. Regression test: scoped package root with an
ephemeral probe now falls back to the running root.

* fix(update): scope running-root selection

* docs(changelog): note npm self-update root fix

* chore(changelog): defer release note

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clownfish Tracked by Clownfish automation maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Openclaw command disappears after brew upgrade installs a new Node major

1 participant