Skip to content

openclaw update misidentifies pnpm 11 global installations as npm #107746

Closed

Description

@kostrse

Summary

openclaw update --dry-run --json reports "mode": "npm" for an OpenClaw installation that was created with pnpm 11 globally. The host runs Arch Linux, has pnpm 11 as the only package manager (npm is not installed), and the active OpenClaw package root resolves into pnpm's global virtual store under store/v11/links/.

The defect is in OpenClaw's package-manager ownership detection: it does not recognize pnpm 11's isolated global-package layout and global virtual store paths. When detection fails, the CLI shared helper (resolveGlobalManager in src/cli/update-cli/shared.ts:303) falls back to "npm" silently.

Confirmed persistent in v2026.7.1 — verified against the pinned release tag. The npm fallback line shifted from 302 → 303 between v2026.6.11 and v2026.7.1, but no pnpm 11 detection fix or test fixture has been included. The resolveGlobalInstallTarget function now accepts an optional packageName parameter, but detection logic is otherwise unchanged.

Environment

  • OS: Arch Linux
  • OpenClaw version: 2026.6.11 (bug confirmed persistent in v2026.7.1)
  • pnpm version: 11
  • npm: not installed
  • Installation style: pnpm add -g openclaw

Expected behavior

{
  "mode": "pnpm",
  "root": "/home/user/.local/share/pnpm/store/v11/links/@/openclaw///node_modules/openclaw"
}

Actual behavior

{
  "mode": "npm",
  "root": "/home/user/.local/share/pnpm/store/v11/links/@/openclaw///node_modules/openclaw"
}

The root is clearly inside pnpm's store, yet the selected update mode is npm.

Root cause

Two related defects:

1. pnpm 11 layout not recognized

OpenClaw's pnpm detection (detectGlobalInstallManagerForRoot in src/infra/update-global.ts) assumes one of:

  • A direct package entry at $(pnpm root -g)/openclaw
  • A .pnpm/.../node_modules/ structure
  • A versioned global directory with pnpm metadata files

In pnpm 11:

  • pnpm root -g returns ~/.local/share/pnpm/global/v11 (the global package directory, not a node_modules)
  • $(pnpm root -g)/openclaw does not exist (pnpm 11 uses isolated install groups with hash symlinks)
  • The active package resolves through store/v11/links/@/openclaw///node_modules/openclaw

The secondary detector inferPnpmGlobalRootFromPackageRoot (src/infra/update-global.ts) only recognizes direct versioned node_modules roots or paths containing .pnpm. A store/v11/links path satisfies neither.

2. Failed detection silently defaults to npm

resolveGlobalManager in src/cli/update-cli/shared.ts:303 converts detection failure into "npm":

const byPresence = await detectGlobalInstallManagerByPresence(runCommand, params.timeoutMs);
return byPresence ?? "npm";

This produces a false npm classification even when npm is absent and the active root is visibly inside pnpm's store.

Note: the lower-level runner (resolveUpdateInstallSurface and runGatewayUpdate in src/infra/update-runner.ts) already handles this correctly by returning mode: "unknown". The unsafe fallback is only in the CLI shared helper used by dry-run and package-install orchestration.

Steps to reproduce

# Install OpenClaw with pnpm 11
pnpm add -g openclaw@latest

# Confirm pnpm version and paths
pnpm --version
pnpm root -g          # returns .../global/v11
pnpm bin -g           # returns .../bin
pnpm store path       # returns store base dir

# Confirm the older expected direct package path is absent
test -e "$(pnpm root -g)/openclaw" && echo "exists" || echo "absent";
# → absent (normal for pnpm 11)

# Confirm npm is absent (if applicable)
command -v npm || echo "npm not installed";

# Observe incorrect updater classification
openclaw update --dry-run --json | jq '{mode, root}';
# → {"mode": "npm", "root": "...store/v11/links/..."}

Impact

  1. Update command failure: On hosts without npm, openclaw update will attempt to invoke a nonexistent command
  2. Wrong installation target: On hosts where npm is also installed, OpenClaw may update an npm global root that doesn't own the active package — creating split installations
  3. Misleading diagnostics: JSON output claims "mode": "npm" rather than indicating detection failed
  4. Auto-update risk: Any automatic update mechanism inherits the misclassification

Suggested fix

Required changes

  1. Recognize pnpm 11 global installations — use authoritative pnpm metadata (pnpm list -g --json openclaw or scanning hash symlinks under global/v11) instead of assuming a direct entry at $(pnpm root -g)/openclaw
  2. Compare realpaths — pnpm 11's install-group node_modules/openclaw may be a symlink into store/v11/links; detection should compare realpath values
  3. Fail closed — resolveGlobalManager should return an explicit unknown result (with a reason) when no manager is proven, rather than defaulting to npm. This requires updating GlobalInstallManager to include an unknown variant
  4. Preserve target identity — the updater must update the installation that owns the active package, not a different package-manager root

Implementation approaches

  • Option A: Use pnpm list -g --json openclaw as the source of truth, parse the dependency entry path, and realpath-compare with the active package root
  • Option B: Implement a scanner for pnpm 11's global/v11 directory: read hash symlinks, resolve install groups, check package.json dependencies, and compare install-group node_modules/openclaw realpaths
  • Option C: Recognize store/v11/links path patterns as supporting evidence, but only accept pnpm ownership after confirming an active global install group points to the same realpath

Related work

None of these address pnpm 11's store/v11/links ownership detection in a merged fix.

Workaround

Update OpenClaw explicitly through pnpm:

pnpm add -g openclaw@latest
systemctl --user restart openclaw-gateway.service

Acceptance criteria

A fix should include tests covering:

  1. pnpm 11 isolated global installation — global/v11/ install group with store/v11/links package root → "mode": "pnpm"
  2. npm absent — pnpm owns OpenClaw, npm not present → no npm fallback
  3. No manager proven → "mode": "unknown" with explicit reason
  4. Duplicate installations — npm and pnpm copies exist, active root belongs to pnpm → pnpm selected
  5. Custom globalDir/storeDir — non-default paths still detected correctly
  6. Managed-service honorPackageRoot — pnpm store node_modules directory never reclassified as direct npm root
  7. End-to-end dry-run — without mocking resolveGlobalManager, target preparation and displayed mode use the same ownership result

Activity

  1. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jul 15, 2026
  2. clawsweeper commented on Jul 15, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 15, 2026, 6:20 AM ET / 10:20 UTC.

    Summary
    Current source still permits the reported misclassification: root ownership detection can remain unresolved while the CLI helper converts that result to npm. The linked closing PR remains open and addresses pnpm 11 link-store recognition but not the generic fallback, so this issue remains necessary pending PR review and a fallback-scope decision. citeturn5view1turn5view2turn6view4.

    Reproducibility: yes. at source level: a pnpm 11 link-store root can miss affirmative ownership detection, and the CLI helper then converts the unresolved result to npm; the issue also supplies a concrete installed-path reproduction. citeturn5view1turn5view2.

    Root-cause cluster
    Relationship: canonical
    Canonical: #107746
    Summary: This issue is the canonical pnpm 11 link-store report; its open PR is a partial candidate fix, while older pnpm updater reports concern earlier layouts or narrower symlink behavior.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    Do not queue a second fix PR while #107802 remains the open closing candidate; maintainer review should scope that branch and the fallback contract.

    Maintainer decision needed

    • Question: Should the current PR remain a scoped pnpm 11 ownership fix, or must it also replace the shared CLI's shipped npm fallback with an explicit unknown result?
    • Rationale: The pnpm 11 detector change is bounded and directly evidenced, while changing the fallback widens the contract for git, package, and unknown-install callers and needs deliberate upgrade behavior.
    • Likely owner: amknight — Their merged updater work most directly owns active package-root detection and package-manager target preservation.
    • Options:
      • Land detection, track fallback (recommended): Review and land the bounded pnpm 11 ownership fix, then handle explicit unknown-mode behavior as a separately specified compatibility change with caller coverage.
      • Expand this fix: Require this PR to add an unknown-manager contract and update every caller with fresh-install and upgrade proof before merge.
      • Preserve npm fallback: Treat npm as the permanent default when ownership is unresolved and close only after pnpm 11 detection lands.
    Review details

    Best possible solution:

    Use one authoritative active-root ownership result across dry-run and execution, recognize verified pnpm 11 link-store installs, preserve their owning target, and make unresolved package ownership explicit without invoking a different manager after compatibility-safe caller updates.

    Do we have a high-confidence way to reproduce the issue?

    Yes at source level: a pnpm 11 link-store root can miss affirmative ownership detection, and the CLI helper then converts the unresolved result to npm; the issue also supplies a concrete installed-path reproduction. citeturn5view1turn5view2.

    Is this the best way to solve the issue?

    Partly: the linked PR is the narrowest immediate fix for the pnpm 11 layout, but the proposed generic unknown-mode change should be separated or explicitly approved because it changes a wider shipped fallback contract.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The open linked PR appears to fix the reported pnpm 11 ownership shape but leaves the separate silent npm fallback unchanged.
    • Changing the generic fallback to fail closed could alter shipped behavior for other ambiguous install kinds, so fresh-install and upgrade behavior across every caller must be reviewed before expanding the PR.

    Codex review notes: model internal, reasoning high; reviewed against c6adbd233b04.

    Label changes

    Label justifications:

    • P0: A supported pnpm 11 global installation can be routed to a nonexistent or non-owning npm command during the built-in update path, with manual terminal recovery required.
    • impact:ux-release-blocker: The normal update flow can stop or split installations, and the available workaround requires direct package-manager commands plus a manual service restart.
    Evidence reviewed

    What I checked:

    • Silent npm fallback remains: resolveGlobalManager asks the root detector, then presence detection, and finally returns npm when both are unresolved. citeturn5view1. (src/cli/update-cli/shared.ts:244, c6adbd233b04)
    • Manager type has no unknown variant: The shared global-install manager type is limited to npm, pnpm, and bun, so this contract cannot express unresolved ownership. citeturn5view0. (src/infra/update-global.ts:27, c6adbd233b04)
    • Lower-level runner fails closed: The package update runner returns a skipped result with mode unknown when root ownership cannot be detected, showing the npm default is not required by the lower-level execution path. citeturn6view4. (src/infra/update-runner.ts:1320, c6adbd233b04)
    • Existing test requires ownership evidence: Updater tests expect root detection to return null when an npm-shaped path lacks its owning npm binary, supporting affirmative ownership detection rather than path-shape guessing. citeturn5view2. (src/infra/update-global.test.ts:261, c6adbd233b04)
    • pnpm installation is supported: The installation documentation presents pnpm as a supported global CLI installation method, making updater ownership for this shape established behavior rather than a new capability. citeturn7search0. Public docs: docs/install/index.md. (docs/install/index.md:55, c6adbd233b04)
    • Open implementation candidate: The supplied GitHub context shows fix(update): preserve pnpm and Bun global installs #107802 is open and unmerged, explicitly closes this issue, and adds pnpm 11 link-store detection without changing the generic CLI npm fallback. (src/infra/update-global.ts, 2f27c497ec41)

    Likely related people:

    • amknight: Authored the merged custom pnpm global-root detection and active-target preservation work that most directly defines the invariant involved here. (role: feature owner; confidence: high; commits: 77480212c714; files: src/infra/update-global.ts, src/infra/update-global.test.ts, src/infra/package-update-steps.ts)
    • Glucksberg: Authored the merged realpath comparison fix for pnpm and bun global-install ownership detection in the same central source file. (role: earlier fix contributor; confidence: medium; commits: a3b82a563dfb; files: src/infra/update-global.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. self-assigned this
    on Jul 15, 2026
  4. locked as resolved and limited conversation to collaborators on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions