Skip to content

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

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

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

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

What Problem This Solves

For a pnpm user: with this PR, openclaw update to 2026.11.10 leaves a working openclaw command. Updates from 2026.11.5 or 2026.11.6 migrate the schema, so the Gateway also restarts by itself; this was verified from 2026.11.5. A same-schema hop, such as one from 2026.11.10-beta.1, 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.

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 can stay stopped.

This backports #201735 to release/2026.11.10. It is a proposal for the release owner. Published 2026.11.10-beta.1 does not contain the fix.

User Impact

What a pnpm user gets when they update to a 2026.11.10 build from this branch:

  • The openclaw command keeps working. 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 when the hop migrates the database schema. The installed updater hands the remaining steps to the new package only then. From 2026.11.5 or 2026.11.6 (agent schema 38, state 36), 2026.11.10 migrates to 42/40, so these hops end with the Gateway serving the new version, with no user step.
  • A same-schema hop is expected to leave the Gateway stopped. An example is a hop from 2026.11.10-beta.1, which was not run here. The installed updater refuses the restart (service-revalidation-failed), as it did on every same-schema hop on the 2026.11.7 line (fix(update): keep the openclaw command and Gateway working after a pnpm update #203401). There, openclaw gateway install --force, then openclaw gateway restart brought the Gateway back. openclaw gateway restart alone does not work.

Why This Change Was Made

This carries the #201735 change (the same commits as before) plus merges of the current release/2026.11.10 tip. It does the following:

  • rewrites pnpm's quoted launcher shim 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 the Doctor launcher repair, plus the Gateway restart on schema-migrating hops.

Commits added on top

On head 6a73e3f, the touched and added tests pass (launcher, relocation, stage, swap, filesystem, service install root, Gateway startup, true-instructions, doctor-health-startup, status.gather, program-args and pnpm owner), along with tsgo:core and tsgo:core:test. Both import-cycle checks report 0, and the baseline ratchets pass in release context. The release tip has since moved to 00f7ee6 with a single UI test change. I merged the tip once before the final cell and did not merge again.

Evidence

Real pnpm update onto this head

Published [email protected] was installed from the public registry with pnpm add -g (pnpm 12.21.0). The Gateway ran as a managed service under the harness's systemd user shim, with a 256 MiB agent database and a busy writer. A plain openclaw update --tag <this head's package tarball, 2026.11.10-beta.2> followed.

Result
openclaw update exit 0, ok, 143 s
openclaw --version OpenClaw 2026.11.10-beta.2 (c979fec)
Launcher exec node "${basedir_abs}"/../global/v11/926ea0a5…/node_modules/openclaw/openclaw.mjs
Gateway serving 2026.11.10-beta.2, readyz true; openclaw gateway status --deep: connectivity ok
Service unit …/store/v11/links/@/openclaw/2026.11.5/… → …/global/v11/926ea0a5…/node_modules/openclaw/dist/index.js
Schema agent/state 38/36 → 42/40 (migrated)
Outage (load probe) 74 s
Disk per directory (peak / left) pnpm home +1064 / +794 MiB; captures +268 / 0 MiB; update temp +896 / +651 MiB

No recovery command was needed. Recording:

r10-pnpm12-2026.11.5-to-r10-c979fec.mp4

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

Checks

Run on 2d90bc4, the first tip merge; c979fec adds the next tip, a single CI test file. The pack ran on c979fec as well.

  • node scripts/run-vitest.mjs passes 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.
  • pnpm tsgo:core, tsgo:core:test, tsgo:extensions:test and tsgo:test:root pass. pnpm check:import-cycles and pnpm check:madge-import-cycles report 0 cycles.
  • pnpm check:baseline-ratchets passes in release context.
  • The branch packs, including runtime-postbuild. The earlier compatibility-inventory pack failure came from the release tip, and it is gone on the current tip.
  • On c979fec, checks-fast-baseline-ratchets was stopped after 46 minutes in "Run baseline ratchets", with no log retained. The same lane passes locally in about 3 minutes, and fix(update): keep the openclaw command and Gateway working after a pnpm update #203401 passed it in CI. The same hang hit fix(update): recognize pnpm 11 group-local virtual stores as global installs #202017 once, and its next run passed. This is attributed to the runner; the new head re-runs it.
  • The earlier red checks came from the release branch (the cachesInstructions type error and a runner download failure). Both are gone after the merge: the type lanes above pass locally on this head.

Not proven

@clawsweeper

clawsweeper Bot commented Nov 19, 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 gateway Gateway runtime cli CLI command changes size: L labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 52ec3c874b9d7253c533630851d8aea132e59cba, but the PR head is now 25c98e8f00b08812ea1251fcf9f88e1bb9b6d754. 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-19T09:13:33.447Z sha 52ec3c8 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 19, 2026
…ATH entries

- Resolve pnpm shims from the physical bin directory whenever the shim
  defines basedir_abs, including the braced form the rewriter emits.
- Keep the forward-slash pass for absolute paths in extensionless shims
  on Windows.
- verifyRuntimeLauncher reports an unknown format from its single
  inspection; the swap turns it into a warning and fails a missing target.
- The launcher repair scan skips FIFOs and other special files instead of
  blocking Doctor or Gateway startup on them.
- Docs: automatic launcher repair is macOS and Linux only.
…ownership on the bytes repaired

- The pre-stop guard refuses only launchers the swap publishes; another
  global package's shim in the staged bin directory no longer fails the
  OpenClaw update.
- A shim resolves physically only when it assigns basedir_abs; a path
  that merely contains the name no longer switches an older lexical
  shim to the physical bin directory.
- Launcher repair checks cmd-shim-target ownership on the same read it
  relocates, and leaves the launcher alone if it changed before the
  rename.
- Doctor, Gateway and docs recovery commands use
  `pnpm add -g --allow-build=openclaw`.
…te launcher tests

- A launcher rewritten in place (Doctor and Gateway repair) does not move
  with its directory, so the stage relocation now applies when the stage
  sits inside that directory, as with pnpm's home-level shim. The updater
  relocates between different directories and is unchanged.
- Fold the apostrophe-in-stage finalize case into the quoted pnpm 12
  layout, the FIFO case into the rewrite cases, the verification cases
  into one table and the service revalidation cases into one table.
  Drop the "recorded target missing" refusal: the ownership check now
  covers it the same way as "another installation".
- Record the remaining 21 regression-test lines over the allowance.
…ery route on refusal

- Move resolvePackageUpdateLauncherNames into the leaf module
  package-update-launcher-names.ts so the native stage no longer imports
  package-update-filesystem (madge cycle through the swap contract), and
  list it in the update-restart swap fixture and PR wrapper inventory.
- Relocate absolute paths with a replacement callback, so `$'` and similar
  in a live path stay literal.
- The pre-stop refusal names the direct pnpm reinstall, the Gateway
  reinstall and restart, and openclaw triage.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 19, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Real pnpm update onto this backport head: passes

The cell started from published [email protected], installed with pnpm 12.21.0 (pnpm add -g), with the Gateway running as a managed systemd user service. It used a 256 MiB database with a writer committing at 1 MiB/s throughout. The candidate is a package built from this PR's head c89a3ee43fc740e06e1d3d5106cf23529f76a8f4 (release/2026.11.10 tip 7750bb308ab plus the fix). It was installed with openclaw update --yes --json --tag <candidate.tgz>, and a second plain openclaw update ran afterwards.

Result
openclaw update exit 0, ok, 193 s
openclaw --version afterwards OpenClaw 2026.11.10-beta.1 (c89a3ee)
Launcher target ../global/v11/926ea…/node_modules/openclaw/openclaw.mjs (live; no .openclaw-update-native-*)
Gateway serving 2026.11.10-beta.1, /readyz 200
Service unit ExecStart …/global/v11/926ea…/node_modules/openclaw/dist/index.js (refreshed)
Schema (agent / state) 38 / 36 → 42 / 40
Gateway outage one, 107 s, starting 79 s after the update began
Peak extra disk (see note) 2159 MiB
Writer 724 commits, 0 busy errors
Second update already-current, 67 s

This hop migrates the schema. Published 2026.11.5 therefore hands the rest of the update to the new package (an update-driver-handoff step appears in the run), and this branch's revalidation restarts the Gateway on the new version.

Negative control. The same cell with the unpatched release/2026.11.6 tip 06afb10 as the candidate bricked the install. openclaw update exited 1, the CLI failed with Cannot find module '…/.openclaw-update-native-0SCSUM/…/openclaw.mjs', the Gateway stayed down, and the second update could not run. The release/2026.11.10 tip has the same launcher code, so it was not run separately. The recording is linked below.

CI on this head. check-test-types is red only on the release branch's inherited error, with the identical result on the bare branch tip 7750bb3:
extensions/openai/openai-api-key-catalog.test.ts(65,27): error TS2339: Property 'cachesInstructions' does not exist on type 'ModelCompatConfig'.
That error comes from the #201094 backport already on this branch. This PR does not touch it.

Note on disk: "peak extra disk" is the drop in free space on the Docker VM's shared filesystem, not a per-directory measurement of the install.

Recordings (cell log streamed live, then a summary read from the raw cell files; host paths replaced with <proof-dir>; container paths under /home/appuser):

  • This head:
bp-pnpm-2026.11.5-to-r10-c89a3ee.mp4
  • Negative control, unpatched release/2026.11.6 tip:
bp-pnpm-2026.11.5-to-r6tip-06afb10.mp4

The full raw logs are not attached. GitHub's attachment route accepts only media, and the Crabbox artifact store rejects uploads from this machine. The decisive lines follow.

This head: steps around the restart (raw openclaw update --json)
candidate-gateway-startup exit 0
update-driver-handoff exit 0
managed-service-executor-check exit 0
managed-service-install exit 0
managed-service-reconciliation exit 0
gateway verification exit 0
{"reason": null, "recovery": {"serviceRestartSafe": true, "version": "2026.11.10-beta.1"}}
Negative control: launcher and CLI after the update
exec node  "$basedir_abs"/'../.openclaw-update-native-0SCSUM/v11/926ea0a51a5e60b563a5c9f5e53c1fda01ec614676ee4355740d8c425a806cdb/node_modules/openclaw/openclaw.mjs' "$@"
Error: Cannot find module '/home/appuser/um/pnpm-home/.openclaw-update-native-0SCSUM/v11/926ea0a51a5e60b563a5c9f5e53c1fda01ec614676ee4355740d8c425a806cdb/node_modules/openclaw/openclaw.mjs'
gateway recovery verification exit 1: … managed-service-ownership (service-ownership-changed) …

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Published 2026.11.6 breaks pnpm installs on update

Setup: published [email protected] was installed with pnpm add -g (pnpm 12.21.0) from the public registry, with the Gateway as a managed service and a 64 MiB database with a writer. A plain openclaw update then moved it to published [email protected]. Nothing but the public registry was involved: no tarball and no test registry.

Result
openclaw update exit 1, service-revalidation-failed, 173 s
openclaw --version afterwards fails: Error: Cannot find module '~/…/pnpm-home/.openclaw-update-native-048neh/v11/926ea…/node_modules/openclaw/openclaw.mjs'
Launcher exec node "$basedir_abs"/'../.openclaw-update-native-048neh/v11/926ea…/node_modules/openclaw/openclaw.mjs' "$@", which points into the removed update stage
Gateway down. The restart and the recovery restart were refused (service-ownership-changed), and the unit still names …/store/v11/links/@/openclaw/2026.11.5/…
Schema (agent / state) 38 / 36, unchanged
Disk, per directory pnpm home +650 MiB, update temp folder +623 MiB (a retained updater runtime and a canary), captures +70 MiB
What 2026.11.5 prints at the end. Both commands it names fail, because the openclaw command itself is broken.
Failing check managed-service-ownership (service-ownership-changed): Required: admitted service ownership owned; manager UID 1001; detected: foreign; runtime stopped; manager UID 1001
Failing check managed-service-ownership (service-ownership-changed): Update install root: ~/…/pnpm-home/global/v11/7fd-18e98510f96e6eb9-0/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/openclaw
Failing check managed-service-ownership (service-ownership-changed): Gateway install root: ~/…/pnpm-home/store/v11/links/@/openclaw/2026.11.5/37a4…/node_modules/openclaw (differs from update install root)
Failing check managed-service-ownership (service-ownership-changed): Different installations: align PATH and use the intended installation's absolute launcher. Gateway service ownership or manager identity changed. Run openclaw gateway status --deep and retry …
Installation recovery is unverified; inspect the installation and backups in ~/…/pnpm-home before restarting.
To start a repair agent, run … openclaw triage --run --update-result …

Both openclaw gateway status --deep and openclaw triage exit 1 with the same Cannot find module error.

Verified recovery, in this order:

  1. pnpm add -g --allow-build=openclaw [email protected]. Exit 0, and openclaw --version prints OpenClaw 2026.11.6. This fixes only the command: the Gateway is still stopped and its service still names the 2026.11.5 path.
  2. openclaw gateway install --force. Exit 0.
  3. openclaw gateway restart. Exit 0. openclaw gateway status --deep then shows Gateway 2026.11.6 running with connectivity ok, and openclaw doctor --non-interactive exits 0.

Layout: a registry target installed by the updater lands in the project-store layout (global/v11/<group>/node_modules/.pnpm/[email protected]_…/node_modules/openclaw), because the updater sets pnpm's virtual store to project. So the earlier tarball-target cells exercised the real target layout. Only a user's own pnpm add -g, as in recovery step 1, puts the package in store/v11/links.

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

pub-pnpm-2026.11.5-to-public-2026.11.6.mp4

For this branch: 2026.11.5 to a 2026.11.10 build with this PR migrates the schema, so the shipped updater hands the rest of the update to the new package, and the earlier cell on this PR ended with exit 0 and the Gateway serving. Without this PR, a 2026.11.10 build has the same launcher break shown above. The release/2026.11.10 tip currently fails its own package build (see the earlier comment), so the cell on the new head has not run yet.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Update: pnpm 11, and the 2026.11.4 start

These cells use the same setup as the comment above: published OpenClaw from the public registry, a plain openclaw update to published 2026.11.6, a managed Gateway, and a 64 MiB database with a writer. Nothing but the public registry was involved.

Start pnpm openclaw update Command afterwards Gateway Schema
2026.11.5 11.28.13 exit 1, service-revalidation-failed, 252 s broken (Cannot find module …/.openclaw-update-native-…/openclaw.mjs) down, restart refused 38/36, unchanged
2026.11.4 12.21.0 exit 1, state-migrated-no-rollback, 177 s; the database rollback was refused broken, same error down, restart refused 27/22 → 38/36, migrated

pnpm 11 users break the same way, and the same recovery works.

  • The pin reached the updater: pnpm --version printed 11.28.13 in the cell, and it was linked at PNPM_HOME/bin/pnpm, which the updater prefers.
  • Recovery:
    1. pnpm add -g --allow-build=openclaw [email protected] → exit 0, and the command prints OpenClaw 2026.11.6;
    2. openclaw gateway install --force → exit 0;
    3. openclaw gateway restart → exit 0. The Gateway serves 2026.11.6 with connectivity ok, and openclaw doctor --non-interactive exits 0.
  • Layout: on pnpm 11 the updater places the target at global/v11/<group>/.pnpm/[email protected]_…/node_modules/openclaw, with .pnpm directly under the group. On pnpm 12 it is <group>/node_modules/.pnpm/….

The 2026.11.4 start is the worse state, and the same three steps recover it with the data intact.

  • After the failed update the data is already migrated to 2026.11.6's schema, the rollback was refused, the command is broken and the Gateway is down.
  • Recovery: the same three steps, then openclaw gateway status --deep shows Gateway 2026.11.6 running with connectivity ok, and openclaw doctor --non-interactive exits 0.
  • Data check: the cell wrote 2000 known rows into the agent database right before the update, in a table the load writer never touches. Count, SHA-256 and PRAGMA quick_check:
Point Rows SHA-256 quick_check Agent schema
before the update 2000 3d587756…b300e9 ok 27
failed state 2000 3d587756…b300e9 ok 38
after recovery and Doctor 2000 3d587756…b300e9 ok 38
  • What openclaw update status reports:
    • In the failed state it cannot run at all; the command is broken.
    • After recovery, the 2026.11.6 command still leads with "⚠️ OpenClaw update failed: post-update-failed" and the historical advice "Run openclaw triage". The recorded recovery is serviceRestartSafe: true (gateway-probe-failed) with no data-at-risk mark, so no stale "keep the Gateway stopped" guidance is shown. The "failed" headline itself remains after the manual recovery.

Recordings:

  • pnpm 11.28.13, 2026.11.5 → 2026.11.6, then the recovery:
pub-pnpm11.28.13-2026.11.5-to-public-2026.11.6.mp4
  • 2026.11.4 → 2026.11.6, then the recovery and the data checks:
pub-pnpm-2026.11.4-to-public-2026.11.6-recovery.mp4

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 20, 2026
…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.
… 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

Replaced by #205078, a single-commit port that applies cleanly to the current release/2026.11.10 head.

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