Repository navigation
fix(update): recognize custom npm prefix installations - #146091
Conversation
Resolve npm ownership from its configured prefix and installed launcher when global-root probes diverge. Share installed-owner detection with update status and include inspected paths in unknown-owner guidance. Refs #146038
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 1:26 PM ET / 17:26 UTC (Revision 7). ClawSweeper reviewWhat this changesRecognizes custom npm installation prefixes through npm configuration and installed launchers, shares detection with update status, and improves unknown-installation guidance. Merge readiness⛔ Blocked before merge - 3 items remain The repair remains necessary and has no identified blocking code defects. The Windows finding is addressed, and the recorded maintainer acceptance satisfies the previous request to explicitly accept the bounded upgrade-proof exception. Priority: P0 Review scores
Verification
How this fits togetherOpenClaw’s updater identifies the package manager responsible for the running installation before selecting its replacement target. This resolver feeds both update admission and installation status. flowchart TD
A[Running installation] --> B[Package manager probes]
B --> C[Installed layout and launcher checks]
C --> D{Owner identified}
D -->|Yes| E[Update target at original prefix]
D -->|No| F[Skipped update with diagnostics]
D --> G[Installation status]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +38, Tests +177, Docs +10. Total +225 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one installation-owner resolver and preserve the original update target under the accepted qualification exception; older-driver recovery should ultimately be exposed through a guided Fix action. Do we have a high-confidence way to reproduce the issue? Yes for the conditional defect: current main returns no owner when global-root probes mismatch and the custom prefix lacks npm despite having an OpenClaw launcher. The exact cause of the reporter's probe mismatch remains unconfirmed. Is this the best way to solve the issue? Yes. Extending the existing resolver and sharing it with status is a focused repair, and the Windows parser now follows npm's shim contract; complete upgrade qualification remains an accepted limitation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 50877be9476d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Check the installed layout before probing npm configuration. Preserve the existing standalone-package command boundary and exercise unknown-owner diagnostics with an orphaned global layout.
Keep custom prefix and lifecycle coverage in the existing npm global suite without increasing the infra test-root budget or dropping assertions.
Select the launcher-relative package argument before percent-star instead of the earlier node.exe existence check. Cover the complete npm-generated shim in the existing custom-prefix ownership regression.
|
@clawsweeper re-review Addressed the Windows npm shim finding in c2731dd. The PR body records the complete-shim failing-before/passing-after regression, focused tests, changed-file checks, and the remaining upgrade-proof limitation. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
Recognize npm ownership for custom prefix installations such as nvm with ~/.npm-global when global-root probes disagree and the prefix has no npm executable. Use npm's configured prefix and the installed OpenClaw launcher, share the resolver with update status, and include inspected paths in unknown-owner refusals. Windows npm shims resolve their package entrypoint instead of the earlier node.exe check. Keep update target selection on the running package prefix. Older installed updaters still need the explicit NPM_CONFIG_PREFIX workaround for the first hop. Full published-driver-to-candidate upgrade preservation remains unverified; focused ownership, target-selection, status, and CLI admission tests pass, including the failing-before/passing-after complete Windows shim regression. Fixes openclaw#146038 Reported by Discord user Rex Horizon in the support thread "As usual update fails" (openclaw#146038).
Fixes #146038
Additional instructions
This branch is in the upstream repository and is available for maintainer edits.
What Problem This Solves
Fixes an issue where users updating an npm installation under a custom prefix such as
~/.npm-globalreceive an unknown-package-manager outcome when npm's global-root probe differs from the running installation. The prefix contains an OpenClaw launcher but normally no npm executable, so the existing fallback discarded valid installation evidence.Reported by a Discord user (Rex Horizon), support thread "As usual update fails" (#146038). The Linux installer and Node installation docs recommend this prefix layout.
Why This Change Was Made
The shared installed-owner resolver now checks npm's configured global prefix using the Node running OpenClaw, leaving npm itself responsible for npmrc precedence and expansion. It also recognizes a global OpenClaw launcher resolving into the corresponding npm package tree when command probes do not match. Windows custom prefixes use the same layout owner. Existing pnpm and Bun detection stays intact, and the selected npm update target remains the running package prefix.
Update status now uses this resolver instead of its separate lockless-package heuristic. Unknown-owner guidance includes the inspected package root, probe results, inferred prefix, and launcher path. Repair and rollback already retain the selected package transaction; Doctor delegates package updates to the same update command.
User Impact
Updates on custom npm prefix installs (nvm +
~/.npm-global) no longer refuse with "package manager owner is unknown" solely because the prefix has no npm executable and the global-root probe differs. Status and update admission agree about installation ownership. Unknown layouts remain unchanged and provide actionable inspection details.Evidence
pnpm install --frozen-lockfile --prefer-offline.node scripts/run-vitest.mjs src/infra/update-runner.test.ts src/infra/update-global-lifecycle.test.ts src/infra/update-global.test.ts src/infra/update-global.bun-owner.test.ts src/infra/update-global.pnpm11-discovery.test.ts src/infra/update-check-status.test.ts src/infra/update-check.test.ts src/infra/update-check-install-kind.test.ts src/infra/detect-package-manager.test.ts src/cli/update-cli/shared.command-runner.test.ts— 335 tests passed across ten files.nullinstead ofnpm; the pinned prefix-probe case also returnednull; unmanaged status reportednpminstead ofunknown; admission lacked inspection diagnostics. All pass with the fix.~/.npm-globallauncher/package,~/.npmrcprefix line, no prefix environment variables. npm 11.19.1, shared update admission, and target selection all resolved the custom npm prefix.node scripts/check-changed.mjs— passed on the final consolidated tree, including core/test typechecks, full core lint, dead-export scans, and zero runtime import cycles.git diff --checkpassed.node scripts/run-vitest.mjs test/scripts/tsgo-core-test-shards.test.ts -t 'covers the repository test roots exactly once with headroom below the hard cap'— passed; the 700-root budget is unchanged.5ac8222475adf21334383ebac679cfb20da54177. The exact-head watcher reports GREEN with zero pending checks after reconciling 12 superseded contexts.Known gaps: the exact reason the reporter's npm probe differed is unconfirmed; stock npm correctly reads an isolated
~/.npmrc. The regression models the observed mismatching probe and proves the missing launcher inference. No full Linux Testbox update/dry-run or published-driver-to-candidate update was run; platform layout tests and the isolated npm/admission proof cover this bounded repair. The installed 2026.9.3 updater cannot acquire this fix before admission; the reporter's explicit prefix environment workaround is still needed to get past that older driver.Latest fixup CI: run 34705209671 at
c2731dda081009379f6661654552872db16db6b4is blocked by checks-node-compact-small-29:test/scripts/tsgo-core-test-shards.test.ts:51reportsgateway-other: 701 test roots exceeds the 700 limit. This is inherited from main: the CI merge6f7bfd32b498b4e4db228633376113c479ba2ac2and its main parent31c8b990cb5c95741796a3c79727cd0dc3e3be4ahave identical gateway tests, shard configs, and shard checker, with 701 matching gateway-other test paths in both. This PR adds no test files. That attempt stopped before the native wrapper; no budget or assertion was weakened. The main shard repair is now present in refreshed merge ref1580397fd2ef54a4c2a73d30446031a50bb62df4(git merge-base --is-ancestor 5587a15c3d1 refs/pull/146091/mergepassed). Fresh pull-request CI https://github.com/openclaw/openclaw/actions/runs/34707801181 passed on the unchanged approved headc2731dda081009379f6661654552872db16db6b4; the exact-head watcher reported GREEN with zero pending checks.ClawSweeper review
Maintainer decision: land this bounded ownership repair with the documented full published-driver upgrade qualification gap. Detection and target-selection evidence do not claim a complete upgrade transition. The lead re-reviewed and approved
c2731dda081009379f6661654552872db16db6b4after the Windows fixup.Applied the Windows npm shim finding: ownership detection now selects the package entrypoint immediately before
%*, skipping npm's precedingnode.exeexistence check. The existing fixture now contains the complete npm-generated shim. With only that fixture changed,node scripts/run-vitest.mjs src/infra/update-global-lifecycle.test.ts -t 'recognizes a custom npm prefix'failed on Windows withexpected null to be 'npm'(1 failed, 2 passed); with the parser fix, 143 tests passed across the lifecycle, global, Bun, pnpm discovery, status, and CLI command-runner suites. The bounded fixup passed Codex autoreview through P2 andnode scripts/check-changed.mjs -- src/infra/update-global.ts src/infra/update-global-lifecycle.test.ts(including core/test typechecks, lint, dead exports, and repository guards).The data-model request is inapplicable:
update-check.tsderives installation status and this diff adds no persistent schema, retention, or recovery changes. Full published-driver-to-candidate preservation proof remains an explicit limitation of this bounded landing, as recorded above; it is not claimed by the layout tests. Older installed updaters still needNPM_CONFIG_PREFIXfor the first hop.