Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep this PR open for now: the central fix is already on current main through the merged replacement #93650, but a member explicitly left this source PR open for review context and contributor follow-up on June 16, 2026. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this PR as superseded by #93650. So I’m closing this here and keeping the remaining discussion on #93650. Review detailsBest possible solution: Close this PR as superseded by #93650. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows the update path uses globalInstallArgs from the resolved install target, and the issue/PR evidence describes a Homebrew Cellar package root whose adjacent npm would previously perpetuate the deleted-prefix trap. Is this the best way to solve the issue? Yes for the merged replacement; it keeps ownership detection while avoiding per-Node npm for reinstall command selection. This source branch is no longer the best merge vehicle because the replacement is already on main and removed the changelog churn. Security review: Security review cleared: The diff changes local npm command selection, focused tests, and changelog text only; it adds no dependency, workflow, secret, permission, or downloaded-code surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against f4e9a6e04780; fix evidence: commit df8ceb526725, main fix timestamp 2026-06-16T13:54:08Z. |
a410b71 to
83f2386
Compare
83f2386 to
0cd09e7
Compare
What an operator hit: A routine `brew upgrade` (or `nvm install` of a new Node major) bumped Node from 25 to 26. Brew deleted the old Node 25 cellar directory. Next shell: `openclaw: command not found`. Their `~/.openclaw/` config was fine, but the CLI itself was gone until they manually re-ran `npm install -g openclaw`, with no obvious clue what they did wrong. Why it kept happening: `openclaw update` was reinstalling openclaw using the npm sitting next to its current install. If that current install was inside a per-Node version-manager directory (Homebrew Cellar, nvm, asdf, volta, fnm, tj/n), the per-version npm has a per-version prefix, so reinstall went back into the same per-version dir. The trap is self-perpetuating, and `openclaw update` could not get an operator out of it. Only an explicit `npm install -g openclaw` invoked through a version-agnostic shimmed npm would relocate openclaw to a stable prefix, and most operators do not know that. What changes: The self-update resolver in src/infra/update-global.ts now recognizes per-Node ephemeral prefixes by path shape and refuses to use the per-version npm in those cases. The existing fallback in resolvePreferredGlobalManagerCommand uses the npm on PATH, which on properly-configured systems lives at a version-agnostic prefix that survives version bumps. Operators currently in the trap are transparently relocated on their next openclaw update. Healthy installs are untouched. Patterns matched (the prefix is the dir holding bin/ and lib/, e.g. /opt/homebrew/Cellar/node/X.Y.Z): Homebrew: .../Cellar/node/<X> or .../Cellar/node@<N>/<X> nvm: .../.nvm/versions/node/v<X> asdf (classic): .../.asdf/installs/nodejs/<X> volta: .../.volta/tools/image/node/<X> fnm: .../.fnm/node-versions/v<X>/installation n (tj/n): .../n/versions/node/<X> Regression test in src/infra/update-global.test.ts covers all six layouts by fabricating each version-manager directory with a real on-disk bin/npm and asserting globalInstallArgs falls back to plain "npm" instead of the per-version path.
0cd09e7 to
bdcb15b
Compare
|
Rebased onto latest P1 fix: added Test gap fix (regression coverage for clawsweeper's concern): new test in Real behavior proof still pending: I do not have a trapped Cellar / nvm install on this machine to capture an after-fix Test-fixture updates: while rebasing, the existing test had to grow Other changes: none. The branch is now a single squashed commit on top of current |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
@clawsweeper re-review Pushed bdcb15b since your last review. Rebased onto main, addressed P1 by splitting ownership detection from preferred-npm selection, added a regression test covering all six trapped layouts. Real behavior proof check went green post-push. Curious if the rating updates. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Clownfish 🐠 reef update Thanks for the contribution. Clownfish hit a branch-permission wall on this PR, so it opened a replacement branch to keep review moving while preserving credit. Replacement PR: #93650 fish notes: model gpt-5.5, reasoning medium; reviewed against 82c8b7c. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
brew upgrade(or any version-manager bump to a new Node major) silently wipes theopenclawcommand. The operator opens a fresh shell and getsopenclaw: command not foundwith no warning.openclaw updatewas the thing keeping them stuck. Each successful self-update was reinstalling openclaw back inside the same per-Node directory the version manager would later delete.npmfrom inside them. The fallback to PATHnpmlands the install at a version-agnostic prefix that survives the next bump./opt/homebrew/lib/node_modules,~/.npm-global,/usr/local, etc.) resolve exactly as before.Change Type
Scope
Linked Issue/PR
Real behavior proof
Behavior or issue addressed: after
brew upgradebumped Homebrew Node from 25.9.0_3 to 26.0.0,openclawwas gone from PATH. The bin shim at/opt/homebrew/bin/openclawpointed inside the deleted Node 25 cellar.Real environment tested: macOS 26.4.1, Apple Silicon, Homebrew Node 26.0.0 (post-upgrade). Live
~/.openclaw/with the gateway service still running off the in-memory copy of the now-deleted Node 25 binary.Exact steps or command run after this patch: applied the same fix to the locally installed
dist/update-runner-DXN2t6wW.jsso the running self-update path picked it up. Reinstalled via the brew-shimmed npm:/opt/homebrew/bin/npm install -g openclaw. Confirmed the install landed at/opt/homebrew/lib/node_modules/openclaw/instead of the cellar. Ranopenclaw --versionandwhich openclaw.Evidence after fix:
Before:
After patch + reinstall:
Observed result after fix:
openclawreachable on PATH again, anchored to the version-agnostic shared prefix. A subsequentnpm install -g openclawbrought 2026.5.7 back, also under/opt/homebrew/lib/node_modules/openclaw/rather than the cellar.What was not tested: live
openclaw updateagainst fresh nvm or asdf installs. Those layouts are covered by the unit test only. The cellar repro is one-shot destructive on a maintainer machine, so re-triggering a real secondbrew upgradeto a new Node major was not done inside this PR.Before evidence: the dangling symlink and
which openclawoutput above are exactly what an operator lands in after a routinebrew upgradethat pulls a new Node major.Root Cause
resolvePreferredNpmCommand(pkgRoot)walks up frompkgRootto find an adjacentbin/npmand returns it. It never checks whether that prefix is a per-Node version-manager directory the manager will later delete. Once openclaw lands in such a directory, every self-update reinstalls back into it.nodeformula bundles its ownnpmwhose default prefix is the cellar. Anything that invokes that bundled npm directly (a post-install script, a CI step, a tooling layer that bypasses the brew shim) lands openclaw inside the cellar. From there, self-update perpetuates it until brew deletes the dir.Regression Test Plan
src/infra/update-global.test.ts, new case covering the cellar / nvm / asdf / volta / fnm / n layouts.pkgRootsits inside a per-Node prefix and the per-versionbin/npmexists on disk,globalInstallArgsandglobalInstallFallbackArgsboth return argv whose first element is the plain"npm"command, not the per-version path.bin/npm, so the existence check inside the resolver would otherwise succeed and the per-version npm would be picked. No live brew, nvm, asdf, volta, fnm, or n needed.lib/node_modulesshape under a brew-prefix root. It still passes after this fix.User-visible / Behavior Changes
Healthy installs see no change. Installs currently anchored inside an ephemeral prefix get relocated to the PATH npm prefix on their next
openclaw update, one-time per affected install. Operators running the daemon-managed gateway will want to restart it after the relocation.Diagram
Security Impact
Repro + Verification
Environment
Steps
/opt/homebrew/Cellar/node/<X>/lib/node_modules/openclaw/. Runbrew upgrade nodeto a new major. Observewhich openclawreturns "not found".openclaw updateagain and confirm the install stays at the same version-agnostic prefix.Expected
openclaw updatefrom inside an ephemeral prefix falls back to PATH npm. The reinstall lands at a stable prefix that survives later version-manager bumps.Actual
After patch, matches expected. Verified via the unit test and the live dist-patch verification on the affected machine.
Evidence
which openclaw,ls -la,readlink,openclaw --version)Human Verification
openclaw --version(returnedOpenClaw 2026.5.2 (8b2a6e5)), reinstalled via the brew-shimmed npm and confirmed openclaw 2026.5.7 landed at the version-agnostic prefix instead of the cellar.node@<N>(versioned formula) alongside the unversionednodeformula. fnm'sinstallationsegment after the version. Stable prefixes on the same machine (/opt/homebrew,~/.npm-global) do not match any pattern and stay unaffected.openclaw updateagainst fresh nvm or asdf installs.pnpm check:changedwas not run in Testbox; targetedpnpm test src/infra/update-global.test.tspasses locally.Review Conversations
Compatibility / Migration
openclaw update.Risks and Mitigations
Cellar/node/<X>,.nvm/versions/node/v<X>, etc.) and will not match generic user-chosen paths. If a false positive ever did occur, the user-visible effect is just falling back to PATH npm.