Skip to content

v2026.5.2: each openclaw plugins install and openclaw doctor --fix wipes other previously-installed @openclaw/* packages from ~/.openclaw/npm/node_modules #76441

Closed

Description

@Wookie1

Environment

  • OpenClaw 2026.5.2 (8b2a6e5)
  • Raspberry Pi 5, Linux arm64, Node 22.22.2
  • Single-user gateway, systemd-managed

Symptom

Running openclaw plugins install <pkgB> after a prior openclaw plugins install <pkgA> removes pkgA's on-disk directory. The install record for pkgA remains in ~/.openclaw/plugins/installs.json, but ~/.openclaw/npm/node_modules/@openclaw/<pkgA> is gone. The gateway then can't load pkgA and emits Config warnings: plugins.entries.<pkgA>: plugin not found: <pkgA> (stale config entry ignored; remove it from plugins config). The same wipe happens on openclaw doctor --fix.

This makes it impossible to have more than one externally-installed @openclaw/* plugin via the CLI — each install resets to a single-plugin state.

Reproduction

Starting from a clean ~/.openclaw/npm/node_modules/@openclaw/ directory:

$ openclaw plugins install @openclaw/discord
Installed plugin: discord
$ ls ~/.openclaw/npm/node_modules/@openclaw/
discord

$ openclaw plugins install @openclaw/acpx@beta
Installed plugin: acpx
$ ls ~/.openclaw/npm/node_modules/@openclaw/
acpx                       # <-- discord is gone

$ openclaw doctor --fix
Updated ~/.openclaw/openclaw.json
$ ls ~/.openclaw/npm/node_modules/@openclaw/
discord                    # <-- acpx is gone

$ cat ~/.openclaw/plugins/installs.json | jq '.installRecords | keys'
[
  "acpx",
  "discord"                # <-- both records still tracked, but only one on disk
]

Likely root cause

~/.openclaw/npm/ has no package.json. openclaw plugins install appears to invoke npm install <pkg> (or equivalent) into that directory. With no package.json to anchor a dependency tree, npm treats every package other than the one you're installing as extraneous and removes it. Each subsequent install/repair therefore yields a single-package node_modules. openclaw doctor --fix repeats the same pattern when reconciling the install records.

Workaround

Manually maintain a package.json at ~/.openclaw/npm/ that lists every installed @openclaw/* plugin as a dependency, then run npm install directly:

$ cat > ~/.openclaw/npm/package.json << 'EOF'
{
  "name": "openclaw-plugins-install-root",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "@openclaw/discord": "2026.5.2",
    "@openclaw/acpx": "2026.5.2-beta.2"
  }
}
EOF
$ cd ~/.openclaw/npm && npm install
$ openclaw plugins enable acpx
$ systemctl --user restart openclaw-gateway.service

After this, both packages coexist and the gateway boots with the full plugin set. The workaround obviously breaks the next time anything calls openclaw plugins install or openclaw doctor --fix, since they presumably overwrite or ignore this package.json.

Suggested fix directions

  1. Have openclaw plugins install maintain a package.json (or equivalent dep manifest) in ~/.openclaw/npm/ that reflects all rows in installs.json before running the npm operation, so the targeted package is added but the others stay in the dep tree.
  2. Or invoke npm with --no-package-lock and --prefer-offline against a synthesized dep tree that includes every previously-installed plugin, so npm doesn't see anything as extraneous.
  3. Or stop using a shared ~/.openclaw/npm/node_modules/ for multi-plugin installs, and instead install each plugin into its own directory keyed off the install record.

Related issues

Activity

  1. clawsweeper commented on May 3, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main already fixes the reported npm pruning path by maintaining a managed package.json in the shared plugin npm root before each npm install, and doctor missing-plugin repair uses that same installer.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the managed npm root manifest fix on main and let the next release carry it to users affected by v2026.5.2.

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

    Yes from source inspection: the reported v2026.5.2 behavior follows from npm installs in a shared root without a dependency manifest, and current main now creates and updates that manifest before install. I did not run a live install because this review is read-only.

    Is this the best way to solve the issue?

    Yes. Maintaining the shared npm root package.json is the narrowest maintainable fix for npm pruning sibling plugin packages, and it also covers the doctor repair path because that path calls the same installer.

    Security review:

    Security review: Non-PR issue triage; no patch security review applies.

    What I checked:

    • Current installer anchors npm dependencies: installPluginFromNpmSpec now calls upsertManagedNpmRootDependency before invoking npm install --prefix, so npm sees existing managed plugins as dependencies instead of extraneous packages. (src/plugins/install.ts:1238, a32fe82bd21b)
    • Managed npm root manifest preserves siblings: The helper reads any existing root package.json, preserves existing dependency entries, and adds the new plugin package dependency. (src/infra/npm-managed-root.ts:48, a32fe82bd21b)
    • Regression coverage covers the core behavior: The managed-root test asserts that adding @openclaw/feishu keeps the existing @openclaw/discord dependency entry in package.json. (src/infra/npm-managed-root.test.ts:24, a32fe82bd21b)
    • Doctor repair uses the same npm installer: Missing configured plugin repair calls installPluginFromNpmSpec, so the doctor repair path benefits from the managed npm root manifest fix. (src/commands/doctor/shared/missing-configured-plugin-install.ts:417, a32fe82bd21b)
    • Fix provenance: The fix/proof commit is fix(plugins): preserve npm plugin installs across repairs, committed at 2026-05-02T18:31:59-07:00. (d7dbf1150432)
    • Release provenance: git tag --contains d7dbf11504326debaa78b0f55df698437e517368 returned no tags, while git branch --contains shows main; this is fixed on current main but not proven shipped in v2026.5.2. (d7dbf1150432)

    Likely related people:

    • @vincentkoc: Authored the current-main fix for preserving npm plugin installs across repairs and adjacent plugin/doctor install cleanup commits in the same area. (role: recent maintainer and fix author; confidence: high; commits: d7dbf1150432, 9765a5777c73, 006bd56dd686; files: src/plugins/install.ts, src/infra/npm-managed-root.ts, src/infra/npm-managed-root.test.ts)

    Codex review notes: model gpt-5.5, reasoning high; reviewed against a32fe82bd21b; fix evidence: commit d7dbf1150432, main fix timestamp 2026-05-02T18:31:59-07:00.

  2. locked as resolved and limited conversation to collaborators on May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions