Skip to content

fix(update): keep the openclaw command and Gateway working after a pnpm update - #203401

Closed
fuller-stack-dev wants to merge 8 commits into
openclaw:release/2026.11.7from
fuller-stack-dev:backport/2026.11.7-pnpm-update-keeps-cli-and-gateway
Closed

fuller-stack-dev wants to merge 8 commits into
openclaw:release/2026.11.7from
fuller-stack-dev:backport/2026.11.7-pnpm-update-keeps-cli-and-gateway

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

For a pnpm user: with this PR, openclaw update to 2026.11.7 leaves a working openclaw command on every hop we ran (from 2026.11.5 and 2026.11.6, on pnpm 12 and 11). When the hop migrates the database schema, the Gateway also restarts by itself. From 2026.11.5 or 2026.11.6 the schema does not change, so the already-installed updater leaves the Gateway stopped. The user then runs openclaw gateway install --force and then openclaw gateway restart; the update output, openclaw update status and openclaw gateway status --deep all name these two commands. From 2026.11.7 onward, updates restart the Gateway by themselves.

Fixes: after openclaw update on a pnpm install (pnpm add -g openclaw), the openclaw command fails with Cannot find module …/.openclaw-update-native-…/openclaw.mjs and the Gateway stays stopped.

This is a backport of #201735 to the 2026.11.7 line, now in preparation. It is a proposal for the release owner; it supersedes #201739, which targeted the already shipped 2026.11.6 line. Published 2026.11.6 and 2026.11.10-beta.1 do not contain the fix.

User Impact

What a pnpm user gets when they update to a 2026.11.7 built from this branch:

  • The openclaw command keeps working on every hop we ran. The installed updater still publishes a launcher that points into its removed update stage, and this package's Doctor repairs it during the same update.
  • The Gateway restarts by itself only when the hop migrates the database schema. The installed updater (2026.11.6 or older) hands the remaining steps to the new package only then. 2026.11.5 and 2026.11.6 have the same schema as 2026.11.7 (agent 38, state 36). On those hops the installed updater still refuses the restart (service-revalidation-failed, exit 1) and leaves the Gateway stopped. The updater that is already installed cannot be patched.
  • On those hops, two commands bring the Gateway back, and this build now says so where the user looks. This was verified in every cell below: openclaw gateway install --force, then openclaw gateway restart. openclaw gateway restart alone does not work, because the service still names the previous version's store directory.
    • During the update, this package's Doctor reports: "If this updater leaves the Gateway stopped, run openclaw gateway install --force and then openclaw gateway restart."
    • Afterwards, openclaw update status and openclaw gateway status --deep give the same pair instead of "Run openclaw triage" or the generic reinstall advice.

Once 2026.11.7 is installed, later pnpm updates run its own updater, which relocates the launcher and revalidates the service against the pnpm install root itself.

Why This Change Was Made

This is one commit with the net change of #201739 (which adapted #201735 to this line), plus a merge of the current release/2026.11.7 tip. It does the following:

  • rewrites pnpm's quoted launcher shim ("$basedir_abs"/'<target>') by value, so every quoting form relocates;
  • refuses to publish a launcher that still names the stage;
  • repairs an already broken launcher from Doctor and Gateway startup;
  • matches the unchanged service definition against its own install root after pnpm repoints the global entry.

The fingerprint, name, profile and manager-UID ownership checks are unchanged.

Update behavior: the fix runs when this package is the updater, the Doctor or the Gateway. Updates driven by an installed 2026.11.6 or older updater get only the Doctor launcher repair, plus the Gateway restart on schema-migrating hops, as described above.

Steps still left to a person: the two Gateway commands on same-schema hops from a shipped updater. They cannot be automated inside that updater, which is already installed. The parked draft #201906 tried an automatic restart after the updater exits; it failed in three real runs and is not part of this PR. The commands are now named during and after the update; triage cannot run them without a terminal. Once 2026.11.7 is the installed updater, no step is left: see the fixed-updater cell below.

Commits on this branch

  1. b84ccfe: the fix: keep the openclaw command and Gateway working after updating a pnpm install #201735 change, the net change of fix(update): keep the openclaw command and Gateway working after a pnpm update #201739 adapted to this line.
  2. 2a2eb41: merge of the release/2026.11.7 tip e0477dd, a single test file.
  3. d5c24e4: cherry-pick of fix(ci): keep launcher repair helper internal #201816, which keeps the launcher repair helper internal; main's dead-export scan needs it.
  4. 91fd884: the true-instructions change from fix(update): name the working Gateway recovery after a shipped pnpm updater leaves it stopped #203406, squashed into one commit:
    • a Doctor warning during the update;
    • the update status next step;
    • the gateway status --deep drift advice;
    • the docs correction.
  5. d3533f0: the pnpm 11 layout detection from fix(update): recognize pnpm 11 group-local virtual stores as global installs #202017, squashed. On pnpm 11, gateway install --force and later updates then save the stable <hash>/node_modules/openclaw entry instead of the per-version directory.
  6. 28407d9: launcher-repair hardening from fix(update): repair only this account's pnpm launcher and never keep set-ID bits #203447. The repair touches only a launcher owned by the current account, never keeps set-ID bits, and uses the same base for detection and relocation; the docs now list 2026.11.6.
  7. 7413c6d and d499c95: the second-update fix from fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update #203458. On pnpm, an update run by an updater that an earlier update installed no longer fails after activating with update-recovery-pending. That failure happened because detached workers were still started from the package activation had just moved away. Without this commit, the first pnpm update after this release would fail falsely, and every later update would be refused.

The tip has since moved to 0bfe6a5, with test and CI-only commits. I merged the tip once before the final cells, as agreed, and did not merge again.

Evidence

Real pnpm updates through the shipped entry point

Each cell installed published openclaw@<start> from the public registry with pnpm add -g, ran the Gateway as a managed service under the harness's systemd user shim, with a 256 MiB agent database and a busy writer, then ran a plain openclaw update --tag <this branch's package tarball>. The target is installed in the same layout class as a registry target. Afterwards the cell ran openclaw gateway install --force and openclaw gateway restart, only if the Gateway was not serving.

Cells on this head, 2a2eb41:

Start → target pnpm openclaw update openclaw --version after Launcher target after Gateway after the update Service unit after the update Schema agent/state After gateway install --force + gateway restart
2026.11.6 → head 12.21.0 exit 1, service-revalidation-failed, 154 s OpenClaw 2026.11.7 (2a2eb41) global/v11/926ea0a5…/node_modules/openclaw/openclaw.mjs stopped store/v11/links/@/openclaw/2026.11.6/… 38/36 → 38/36 both exit 0; running, connectivity ok; unit on global/v11/926ea0a5…/node_modules/openclaw
2026.11.5 → head 12.21.0 exit 1, service-revalidation-failed, 153 s OpenClaw 2026.11.7 (2a2eb41) same stopped …/openclaw/2026.11.5/… 38/36 → 38/36 both exit 0; running, connectivity ok; unit on global/v11/926ea0a5…/node_modules/openclaw
2026.11.6 → head 11.28.13 exit 1, service-revalidation-failed, 166 s OpenClaw 2026.11.7 (2a2eb41) global/v11/9440847f…/node_modules/openclaw/openclaw.mjs stopped …/openclaw/2026.11.6/… 38/36 → 38/36 both exit 0; running, connectivity ok; unit on the per-version global/v11/<group>/.pnpm/openclaw@file+…/node_modules/openclaw (see below)
Negative control: 2026.11.6 → bare tip d3b5796 12.21.0 exit 1, service-revalidation-failed, 165 s fails: Cannot find module …/.openclaw-update-native-fPbx97/…/openclaw.mjs "$basedir_abs"/'../.openclaw-update-native-fPbx97/…/openclaw.mjs', the removed stage stopped …/openclaw/2026.11.6/… 38/36 → 38/36 not run; the command itself is broken
  • Outage. The load probe measured the Gateway from its stop until it served again: 238, 254 and 247 s. That window includes the update and the two commands, which the cell ran immediately after the update. For a user, the outage lasts until they run them. On the bare tip the Gateway was still down when the load window closed (342 s).

  • Disk. Sampled per directory through the update, as peak / left afterwards:

    • pnpm home: +855 / +855 MiB on pnpm 12, +1155 / +1155 MiB on pnpm 11 (the new package version);
    • update captures: +268 / +268 MiB;
    • the update's temp directory: about +900 / +630 MiB.

    These are the cell's own paths, not the shared VM disk.

  • pnpm 11 service path. After gateway install --force, the pnpm 11 service names the per-version .pnpm/openclaw@… directory instead of the stable entry, and the next update removes that directory. fix(update): recognize pnpm 11 group-local virtual stores as global installs #202017 fixes this on main and is proposed for this branch.

  • Cells on b84ccfe. The same cells were also run on b84ccfe, this commit before the test-only tip merge, with identical outcomes.

Recordings (cell log live, then a summary from the raw cell files; container paths under /home/appuser):

2026.11.6 → head, pnpm 12:

r7-pnpm12-2026.11.6-to-r7-2a2eb41.mp4

2026.11.5 → head, pnpm 12:

r7-pnpm12-2026.11.5-to-r7-2a2eb41.mp4

2026.11.6 → head, pnpm 11.28.13:

r7-pnpm11-2026.11.6-to-r7-2a2eb41.mp4

Negative control, 2026.11.6 → bare tip:

r7-pnpm12-2026.11.6-to-r7tip-d3b5796.mp4

Cells for the added commits, on 2a2eb41 plus the squashed true-instructions commit

Cell openclaw update Doctor note during the update update status next step gateway status --deep drift advice Gateway at the end
2026.11.5 → with the commit, pnpm 12.21 exit 1, service-revalidation-failed (shipped updater) the sentence, first warning of the openclaw doctor step "Run openclaw gateway install --force, then openclaw gateway restart." the same pair running after the two commands
same, pnpm 11.28.13, human output exit 1 printed in the update's progress output the pair the pair running after the two commands
npm 2026.11.5 → with the commit exit 0, ok none none no drift serving 2026.11.7 by itself
Fixed updater: this build as 2026.11.7-beta.1 → this build, pnpm 12.21 exit 0, ok none none no drift serving 2026.11.7 by itself, outage 91 s; unit refreshed to global/v11/926ea0a5…/node_modules/openclaw

The 2026.11.5 → head row in the first table is the red counterpart: no note, and update status ends with "Historical recovery advice: Run openclaw triage …". The full cell table, recordings and the triage behavior are on #203406. The fixed-updater recording:

jt-pnpm12-fixed-r7jt-to-r7jt-eef73b5.mp4
What the 2026.11.6 → head cell printed after the update, then the two recovery commands
$ openclaw --version
OpenClaw 2026.11.7 (2a2eb41)
$ openclaw gateway status --deep        (excerpt)
Runtime: stopped (state inactive, sub dead, last exit 0, reason exited)
CLI 2026.11.7 at ~/…/global/v11/…/node_modules/openclaw differs from the Gateway service's 2026.11.6 at ~/…/store/v11/links/@/openclaw/2026.11.6/…/node_modules/openclaw. Run `openclaw update` or use the CLI from … Run `openclaw doctor --fix` or `openclaw gateway install --force` from the active CLI.
Connectivity check: failed
$ openclaw gateway install --force
Installed systemd service: ~/.config/systemd/user/openclaw-gateway.service
Previous unit backed up to: ~/.config/systemd/user/openclaw-gateway.service.bak
exit 0
$ openclaw gateway restart
Restarted systemd service: openclaw-gateway.service
exit 0
$ openclaw gateway status --deep        (excerpt)
Command: /usr/local/bin/node --max-old-space-size=4096 ~/…/global/v11/926ea0a5…/node_modules/openclaw/dist/index.js gateway --port …
Runtime: running (pid …, state active, sub running)
Connectivity check: ok
Negative control: the same hop onto the bare release/2026.11.7 tip
$ openclaw --version
Error: Cannot find module '~/…/pnpm-home/.openclaw-update-native-fPbx97/v11/926ea0a5…/node_modules/openclaw/openclaw.mjs'
$ grep exec ~/…/pnpm-home/bin/openclaw        (excerpt)
exec node  "$basedir_abs"/'../.openclaw-update-native-fPbx97/v11/926ea0a5…/node_modules/openclaw/openclaw.mjs' "$@"

Full raw logs are not attached, because the artifact store rejected uploads from the test host.

Checks on this branch

Run on head d3533f0, with the bare tip as comparison where something failed:

  • node scripts/run-vitest.mjs on the launcher repair, runtime relocation, native stage, all package-update-swap*, package filesystem, service install root, Gateway startup plugin, update-restart module outcome and eager import closure tests pass, together with the true-instructions, doctor-health-startup, status.gather, program-args and pnpm owner tests.
  • pnpm tsgo:core and pnpm tsgo:core:test pass. pnpm check:import-cycles and pnpm check:madge-import-cycles report 0 cycles. pnpm check:docs and git diff --check pass.
  • The branch packs: node scripts/package-openclaw-for-docker.mjs runs runtime-postbuild (14 phases) and the tarball integrity check passes. The bare tip packs too. This line has no compatibility-inventory pack failure; 2026.11.10 had one.
  • pnpm check:baseline-ratchets passes with the release context that a PR into release/* gets in CI, where the test-line budget is skipped. Run as a main-line branch, only test-lines fails: the bare tip is already 695 lines over its ceiling, and this branch adds the 424 net regression-test lines that fix: keep the openclaw command and Gateway working after updating a pnpm install #201735 added on main.

CI on 2a2eb41 passed every check (75 pass, 58 skipped). CI on d3533f0 also passed every check (77 pass, 60 skipped).

Cherry-pick for the release line

There are six commits; see "Commits on this branch". Each touches only files that exist on this line, and none needs main-only code. On the branch they pass the touched tests and both type lanes, and both import-cycle checks report 0. The squashed commits apply unchanged to release/2026.11.10 (#201740).

Not proven

Review notes

ClawSweeper round 1 on 2a2eb41 rated it F / C / F. Here is each finding and what this branch does about it:

…pm update

Backport of openclaw#201735 to the 2026.11.7 line, as adapted and proven for the
2026.11.6 line in openclaw#201739: rewrite pnpm's quoted launcher shim by value,
repair launchers left pointing into an update stage, and revalidate the
managed service against the pnpm install root.
…/2026.11.7-pnpm-update-keeps-cli-and-gateway
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts size: XL labels Nov 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 2a2eb418eef6d582fb55a90bab1fc6eee6b266ee, but the PR head is now d3533f0bf94a5016588d7d41fe4853d54ed35d41. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-22T04:20:47.281Z sha 2a2eb41 :: blocked before merge. :: [P2] Document the same-schema first-hop recovery requirement

…updater refuses the restart

Shipped updaters 2026.11.4 through 2026.11.6 refuse the Gateway restart
after a same-schema pnpm update (`service-revalidation-failed`) and leave
the Gateway stopped. The verified recovery is `openclaw gateway install
--force` followed by `openclaw gateway restart`; `gateway restart` alone
fails while the service still names the previous store directory.

One module decides that state: on macOS or Linux, the service this pnpm
installation owns and may rewrite still names another version's package
in the same pnpm home, and no other active global project uses it.

- Doctor, run by such an updater, returns the pair as an update warning
  once it had to repair the launcher that updater published (the marker
  of a shipped driver); shipped updaters render it in their final report.
- `openclaw update status` names the pair as the next step for a
  `service-revalidation-failed` run while the Gateway is not responding
  and its service is stopped.
- `openclaw gateway status --deep` names it in the installation drift line
  while the service is stopped.
- Both commands carry the reader's profile.
- The update docs no longer claim that these updaters always hand the
  restart to the new package.

Squashed from openclaw#203406.
…nstalls

pnpm 11.28 installs a global package into `<group>/.pnpm/...`; layout
inference accepted only `<group>/node_modules/.pnpm/...`, so such an
install was classified as an unmanaged package root and the refreshed
service definition pinned the per-version directory pnpm removes on the
next update.

Squashed from openclaw#202017.
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 22, 2026
… bits, from the shim's own base

- Launcher repair leaves a launcher owned by another account unchanged and
  reports why (uid of the owner and of this account) through the existing
  failed-repair message, instead of replacing it with this account's file.
- The replacement keeps permission bits only; setuid, setgid and sticky
  bits are never carried into a rewritten launcher.
- Detection and relocation share one answer for the base a shim's
  `$basedir` resolves from (physical only when the shim defines
  `basedir_abs`), so a symlinked bin directory cannot make them disagree.
- The update guide lists 2026.11.6 among the updaters that miss these
  steps and states the ownership rule.
… after activation

A pnpm updater that a previous OpenClaw update installed runs from its
group's project-local virtual store. Activating the next version moves
that group into the transaction backup, so the running updater's own
`dist` disappears. Work started inside the update loads workers through
the retained-runtime generation, but process-wide owners that start
workers from detached or earlier async contexts (the state lease
heartbeat carrier, the file-log worker pool) still resolved them from the
installed package. Their spawns failed with `Cannot find module`, the
plugin lifecycle lease was lost, and the update unwound as
`update-recovery-pending` while the new Gateway was already serving.

The retained-runtime generation now also registers a process-wide
resolver for as long as it is bound, and `createCpuTrackedWorker`, which
every tracked worker spawn goes through, applies it. Async-context
bindings keep precedence; nothing changes outside an update that
retained its runtime.

Release-line form of openclaw#203458; this line needs no type move.
…nly once

A worker captured inside the generation was resolved again by the
process-wide resolver at spawn time. The retained-runtime mapping is
idempotent, but a generation's resolver need not be: the heartbeat
generation test's wrapping resolver then imported itself and the worker
never started (Bun shard timeout). A URL the generation already produced
is now final.
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

2026.11.7 is now latest on npm (published 2026-11-23 01:21 UTC, built from e31bbf0) without this change. I ran the real published packages through a pnpm update and through this PR's head merged onto the tag.

Setup. Linux container, systemd as PID 1, user Gateway service, pnpm 12.21.0, Node 24.22.1, a 256 MiB agent database with a busy writer, synthetic state. The update command was openclaw update --yes.

Step Exit openclaw --version after Gateway after
published 2026.11.6 → published 2026.11.7 1 after 146 s MODULE_NOT_FOUND stopped from 58 s in, did not come back in 10 min
manual recovery: pnpm add -g [email protected], openclaw gateway install --force, openclaw gateway restart 0 after 15 s 2026.11.7 serving 2026.11.7
2026.11.7's own updater → next version without this PR 1 after 146 s MODULE_NOT_FOUND again stopped again
published 2026.11.6 → v2026.11.7 + this PR (d499c95) 1 after 144 s works, new version stopped; Doctor and update status name openclaw gateway install --force then openclaw gateway restart
those two commands 0 after 14 s works serving
that build's own updater → next version 0 after 183 s works restarted by the updater, 84 s outage

So with 2026.11.7 as published, every pnpm update to it or from it leaves a broken command and a stopped Gateway, and the only next step the update prints is openclaw triage, which cannot start because openclaw is the broken command. With this PR the command survives and the messages name commands that work; the first update driven by an already-published updater still stops the Gateway, because that updater cannot be changed from here. Later updates need no manual step.

published 2026.11.6 → published 2026.11.7: decisive output
$ openclaw --version
Error: Cannot find module '/home/appuser/um/pnpm-home/.openclaw-update-native-FDtx3i/v11/<hash>/node_modules/openclaw/openclaw.mjs'
  code: 'MODULE_NOT_FOUND'

Failing check managed-service-ownership (service-ownership-changed): Required: admitted service ownership owned; manager UID 1001; detected: foreign; runtime stopped; manager UID 1001
Update install root: /home/appuser/um/pnpm-home/global/v11/<group>/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/openclaw
Gateway install root: /home/appuser/um/pnpm-home/store/v11/links/@/openclaw/2026.11.6/<hash>/node_modules/openclaw (differs from update install)
Recorded verification: service stopped; channels not ready; HTTP not ready; core not ready.
Run `openclaw triage` on this machine to open a coding agent that can diagnose and repair the installation.

npm installs on the main-line targets I ran alongside were unaffected. Not covered here: pnpm 11 and npm on the 2026.11.7 hops, macOS/launchd, Windows, Bun. Full raw logs are not attached because the artifact store rejects uploads from this machine.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Follow-up runs for people already on published 2026.11.7, same cell shape as above (systemd user service, busy database writer, openclaw update --yes). Starting installs are the real published packages; the candidate next releases are local builds labelled with higher versions.

Start Target Exit openclaw after Gateway after Manual commands
npm, published 2026.11.6 published 2026.11.7 0 works serving, 92 s outage 0
npm, published 2026.11.7 v2026.11.7 + this PR 0 works serving, 89 s outage 0
pnpm 11.29.0, published 2026.11.6 published 2026.11.7 1 MODULE_NOT_FOUND stopped 3 (reinstall with pnpm, gateway install --force, gateway restart)
pnpm 12.21.0, published 2026.11.7 v2026.11.7 + this PR 1 works stopped, still down after 7 min 2 (gateway install --force, gateway restart)
that install the same build's next version 0 works serving, 89 s outage 0
pnpm 12.21.0, published 2026.11.7 main at 82848e3 (schema 36/38 → 41/43) 0 works serving, 73 s outage 0
that install main + one commit 0 works serving, 12 s outage 0

What this shows:

  • npm installs are not affected on these hops.
  • pnpm 11 fails on the published 2026.11.7 update the same way pnpm 12 does.
  • With this PR as the next release on this line, a pnpm user on 2026.11.7 keeps a working command, and the update names the two commands that bring the Gateway back. The Gateway still stops on that first hop, because the published 2026.11.7 updater refuses the restart (service-revalidation-failed) when the schema is unchanged.
  • A next release that migrates the schema, such as one built from current main, updated a pnpm install on published 2026.11.7 with no manual command.

Not covered: macOS/launchd, Windows, Bun, Gateway-started updates on these hops.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Closing with #204716. 2026.11.10 has been npm latest since November 25, so openclaw update no longer selects 2026.11.7, and a corrected 2026.11.7 would reach nobody. The update from 2026.11.9 to the published 2026.11.10 on pnpm exited 0 in three runs; installs that are already stuck have the three commands in #204836.

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 gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants