Skip to content

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

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

fuller-stack-dev wants to merge 8 commits into
openclaw:release/2026.11.6from
fuller-stack-dev:backport/2026.11.6-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

Backport of #201735 (proposal for the release owner; do not merge without the release owner's decision).

On pnpm-managed installs (pnpm add -g openclaw), openclaw update can leave no working openclaw command, because the launcher points into the removed update stage, and on pnpm 11.28/12.21 a Gateway that is refused restart and stays down. This was measured with published 2026.11.4 updating to public 2026.11.5.

User Impact

User impact: pnpm installs update to a working CLI and a Gateway that serves the new version. Launchers already broken by an earlier updater are repaired by this release's Doctor and Gateway startup, without a user command.

Why This Change Was Made

This carries the same commits as the main PR, cherry-picked cleanly onto this branch. It relocates and verifies pnpm's quoted shim form ("$basedir_abs"/'target'). It refuses to finalize a launcher that still names the stage, and fails an update whose published launcher cannot start instead of reporting success. Service revalidation now matches the unchanged definition against its own installation root after pnpm repoints the global entry into its versioned store. The fingerprint, name, profile and manager-UID protection is unchanged.

This branch now also includes the apostrophe and quoting fix. Launcher relocation parses each shell word, rewrites its value and quotes it again, so a pnpm home or global directory containing ', ", $, a space or a backslash relocates correctly, including pnpm's '\'' spelling of the stage in NODE_PATH. A repair reports success only when nothing in the launcher still names the stage. It also includes the later review fixes from the main PR:

  • the pre-stop guard checks only the launchers the swap publishes;
  • a shim resolves physically only when it assigns basedir_abs;
  • repair checks ownership on the same bytes it rewrites, skips FIFOs and other special files, and handles pnpm's home-level shim;
  • the recovery command is pnpm add -g --allow-build=openclaw openclaw@<installed-version>;
  • the launcher-name helper is a leaf module (package-update-launcher-names.ts), so the native stage adds no import cycle;
  • a $' in a live path stays literal during relocation;
  • the pre-stop refusal names the direct pnpm reinstall, the Gateway reinstall and restart, and openclaw triage.
    On this branch the cherry-pick dropped the import change for package-update-release-switch.ts, which does not exist on 2026.11.6.

The main PR lists the remaining follow-ups; they are not part of this backport.

Evidence

  • On release/2026.11.6: 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 passes (258 tests). pnpm check:import-cycles and pnpm check:madge-import-cycles report 0 cycles, and pnpm tsgo:core and pnpm tsgo:core:test pass.
  • End-to-end proof is on the main PR, from real pnpm 12.21.0 cells: published 2026.11.4 and 2026.11.5 updating to the fixed build (the first hop), and fixed build to fixed build. Both end with a working CLI and the Gateway serving the new version.

Not proven

  • Target layout from a registry: now covered. A real cell ran published 2026.11.5 → a plain openclaw update → published 2026.11.6 from the public registry only. The updater installs a registry target in the project-store layout (global/v11/<group>/node_modules/.pnpm/openclaw@<version>…), the same layout class the earlier tarball-target cells used. See fix(update): keep the openclaw command and Gateway working after a pnpm update #201739 (comment).
  • Still unproven: a fixed target installed from a registry. It cannot be exercised before a fixed version is published; the fixed builds were proven as tarball targets.
  • Still unproven: pnpm 11, which ignores the virtualStoreType=project setting the updater passes, so its target layout may differ. A pnpm 11 cell is being prepared.

@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 5f216cd3fa3774c51d628efb6095b4e647e79ec6, but the PR head is now 848912c7ae717858524eb14fe973d787878b4381. 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:39.000Z sha 5f216cd :: 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: the CLI works, but the Gateway stays down until the next update

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 848912c7ae717858524eb14fe973d787878b4381 (release/2026.11.6 tip 06afb10d327 plus the fix). It was installed with openclaw update --yes --json --tag <candidate.tgz>. A second plain openclaw update ran afterwards.

First update (2026.11.5 updater) Second update (2026.11.6 updater)
openclaw update exit 1, service-revalidation-failed 0, ok
Wall time 167 s 218 s
openclaw --version afterwards OpenClaw 2026.11.6 (848912c) OpenClaw 2026.11.6 (848912c)
Launcher target ../global/v11/926ea…/node_modules/openclaw/openclaw.mjs (live; no .openclaw-update-native-*) same
Gateway down, restart refused: managed-service-ownership (service-ownership-changed) serving 2026.11.6, /readyz 200
Service unit ExecStart still …/store/v11/links/@/openclaw/2026.11.5/…/dist/index.js …/global/v11/926ea…/node_modules/openclaw/dist/index.js (refreshed)
Schema (agent / state) 38 / 36, unchanged 38 / 36
Gateway outage 402 s, from 66 s after the first update started until the second update restarted it
Peak extra disk 1162 MiB
Writer 537 commits, 0 busy errors

What this shows. The launcher half of the fix works on the first hop: the CLI runs 2026.11.6 and the launcher names the live install. The Gateway half does not. The published 2026.11.5 updater refuses to restart the Gateway, and the Gateway stays down until the next openclaw update, which this branch's updater runs correctly.

Root cause.

  • Published 2026.11.5 hands the rest of an update to the new package only when the new package migrated the schema. The check is inspectActivatedUpdateState returning state-migrated-no-rollback (src/cli/update-cli/update-command-migrated.ts:141-146 at v2026.11.5), which leads to continueMigratedUpdateInFreshProcess.
  • 2026.11.6 has the same schema as 2026.11.5 (38/36), so no handoff happens. The 2026.11.5 updater runs its own service revalidation, which still has the bug this PR fixes: it checks the service against the pnpm global entry that the swap just repointed, sees "foreign", and refuses the restart and the recovery restart.
  • On main the same first hop works only because that target migrates the schema (38/36 → 43/40), so 2026.11.5 hands off (update-driver-handoff step) to code with the fix.
  • The release/2026.11.10 target also migrates the schema; its cell follows below.

This backport cannot fix that hop from the candidate side as it stands. The published updater makes the refusal before any new code gets control. I am reporting this to the release owner and have changed nothing.

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

bp-pnpm-2026.11.5-to-r6-848912c.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.

First update: failed steps and recovery (raw openclaw update --json)
package-swap exit 0: Published launcher /home/appuser/um/pnpm-home/bin/openclaw could not be verified: Cannot resolve the launcher's executable target. Reinstall the current openclaw version with pnpm to recreate the launcher.
openclaw doctor exit 0 (… Doctor: CLI launcher …)
package-backup-retention exit 1: Installation recovery is unverified; inspect the installation and backups in /home/appuser/um/pnpm-home before restarting.
gateway recovery verification exit 1: Failed to restart managed gateway service after failed update: GatewayServiceUpdateOwnershipError: Failing check managed-service-ownership (service-ownership-changed): Required: admitted service owner
{"reason": "service-revalidation-failed", "recovery": {"serviceRestartSafe": true, "version": "2026.11.6", "reason": "gateway-probe-failed"}}
Launcher after the first update
exec "$basedir/node"  "${basedir_abs}"/../global/v11/926ea0a51a5e60b563a5c9f5e53c1fda01ec614676ee4355740d8c425a806cdb/node_modules/openclaw/openclaw.mjs "$@"
# cmd-shim-target=/home/appuser/um/pnpm-home/global/v11/926ea0a51a5e60b563a5c9f5e53c1fda01ec614676ee4355740d8c425a806cdb/node_modules/openclaw/openclaw.mjs
Second update (driver 2026.11.6)
repeat result: ok | before: 2026.11.6 | after: 2026.11.6
managed-service-reconciliation exit 0: Refreshed Gateway service definition.
gateway serving: {"version": "2026.11.6"} | readyz: true

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

What this backport fixes today, and what it does not yet

All the cells below start from published OpenClaw installed with pnpm 12.21.0 and the Gateway as a managed service. Each uses a 256 MiB database with a writer, and runs openclaw update --tag <candidate> with the candidate built from the named commit.

Start Candidate Schema openclaw update CLI afterwards Gateway afterwards
2026.11.5 unpatched release/2026.11.6 tip 06afb10 38/36 → 38/36 exit 1 broken: launcher points into the removed .openclaw-update-native-* stage down, not recovered; the next update cannot run
2026.11.5 this PR 848912c 38/36 → 38/36 exit 1, service-revalidation-failed works, 2026.11.6 (848912c) down for 402 s, until a second plain openclaw update restarts it
2026.11.4 this PR 848912c 27/22 → 38/36 exit 0 works serving 2026.11.6, one 99.5 s outage
2026.11.5 #201740 c89a3ee 38/36 → 42/40 exit 0 works serving 2026.11.10-beta.1, one 107 s outage

Fixed by this backport: the openclaw command. On every hop tested, the launcher names the live install and the CLI runs the new version. Without the backport, the CLI is gone and no further command works.

Not yet fixed: the Gateway restart on a same-schema hop from 2026.11.5.

  • Published 2026.11.5 hands the rest of an update to the new package only when the schema migrates. 2026.11.5 → 2026.11.6 does not migrate, so 2026.11.5 restarts the Gateway itself, and its unfixed revalidation refuses.
  • The 2026.11.4 start and the 2026.11.10 target both migrate, which is why they work.
  • An automatic fix for this hop is being built on main first. It will then be added to this branch as one more commit, with the same cells rerun.

Until then, the verified recovery on that hop is a second plain openclaw update. In the cell it returned ok in 218 s, refreshed the service definition and restarted the Gateway on 2026.11.6. A separate cell is checking the individual openclaw gateway commands in that state, and its result will follow here.

Recording of the 2026.11.4 → 848912c cell:

bp-pnpm-2026.11.4-to-r6-848912c.mp4
2026.11.4 → 848912c: steps around the restart
update result: ok | before: 2026.11.4 | after: 2026.11.6
update-driver-handoff exit 0
managed-service-install exit 0
managed-service-reconciliation exit 0
gateway verification exit 0
gateway serving: {"version": "2026.11.6"} | readyz: true

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Verified recovery for the same-schema hop from 2026.11.5

This was a real cell in the failure state described above: published 2026.11.5 → this PR's head 848912c, with the Gateway down after openclaw update exited 1 (service-revalidation-failed). Each command was run in order, with a status check after each.

Command Result
openclaw gateway status --deep Service runs the 2026.11.5 store path, stopped, connectivity failed
openclaw gateway restart exit 1: "Gateway restart failed after 14s: service stayed stopped and port … stayed free", lastExit=78
openclaw gateway install --force exit 0: "Installed systemd service … Previous unit backed up"
openclaw gateway restart exit 0
openclaw gateway status --deep Gateway 2026.11.6 running, connectivity ok
openclaw doctor --non-interactive exit 0
openclaw --version OpenClaw 2026.11.6 (848912c)

Shortest working recovery: openclaw gateway install --force, then openclaw gateway restart. openclaw gateway restart alone does not work in this state, because the service definition still names the previous version's store path. A second plain openclaw update also recovers, in about 218 s.

The automatic fix is the draft #201906 on main. After the installed updater exits, the new package refreshes the service definition and starts the Gateway itself. It will be added to this branch as one commit once it lands, with the real cells rerun here.

@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: the table shows the shipped 2026.11.6, which does not contain this PR. With this PR, the same hop from 2026.11.5 keeps a working command: this package's own Doctor repairs the launcher during the update. The Gateway restart is still refused on this same-schema hop until #201906 lands and is added here; the earlier comments have those cells.

@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
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Superseded by #203401, which carries the same change for release/2026.11.7, the line now in preparation. 2026.11.6 has already shipped without this fix, so this branch can no longer reach users. Closing in favor of #203401. The cells and recovery notes in the comments above still describe published 2026.11.6.

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.

1 participant