openclaw - ✅(Solved) Fix [Bug]: @openclaw/codex peerDependency link not created on install — gateway lanes crash with ERR_MODULE_NOT_FOUND for openclaw/plugin-sdk/* [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77959Fetched 2026-05-06 06:18:46
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Author
Timeline (top)
cross-referenced ×2commented ×1subscribed ×1

After updating to OpenClaw 2026.5.4 on a Homebrew-managed install, every main-session lane crashes immediately with ERR_MODULE_NOT_FOUND because @openclaw/[email protected] cannot resolve openclaw/plugin-sdk/* at runtime. The plugin declares peerDependencies: { "openclaw": ">=2026.5.3" } correctly, but linkOpenClawPeerDependencies() did not create the expected node_modules/openclaw symlink inside the installed plugin directory, so Node's resolver has nothing to walk to.

The result is total main-channel blackout: Telegram, Mission Control chat, and the gateway Control UI all stop receiving/sending messages even though the gateway process itself reports healthy.

Error Message

lane task error: lane=session:agent:main:main durationMs=663 error="Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from /Users/<user>/.openclaw/npm/node_modules/@openclaw/codex/dist/client-chGfNrq5.js"

Root Cause

After updating to OpenClaw 2026.5.4 on a Homebrew-managed install, every main-session lane crashes immediately with ERR_MODULE_NOT_FOUND because @openclaw/[email protected] cannot resolve openclaw/plugin-sdk/* at runtime. The plugin declares peerDependencies: { "openclaw": ">=2026.5.3" } correctly, but linkOpenClawPeerDependencies() did not create the expected node_modules/openclaw symlink inside the installed plugin directory, so Node's resolver has nothing to walk to.

Fix Action

Fix / Workaround

Local workaround

To make the workaround survive openclaw update, we re-assert the symlink at the top of our recovery-check cron and a post-upgrade-verify script. With those guards, recovery is automatic within ~5 minutes after any future regression of the same shape.

PR fix notes

PR #78045: fix: relink managed plugin openclaw peers on boot

Description (problem / solution / changelog)

Summary

Re-assert the host openclaw peerDependency link for enabled managed installed plugins during gateway startup, before runtime plugin imports. This gives installs updated outside the plugin install path (for example Homebrew replacing the host package) a cheap boot-time self-heal instead of crashing lanes with ERR_MODULE_NOT_FOUND for openclaw/plugin-sdk/*.

Changes

  • Add boot-time managed-plugin peer relink helper in plugin-peer-link.ts.
  • Invoke the helper after plugin lookup/index resolution and before startup plugin runtime loading.
  • Add regression coverage for re-linking a managed installed plugin declaring peerDependencies.openclaw.

Testing

  • PATH="/tmp/openclaw-pnpm-shim:$PATH" node scripts/test-projects.mjs src/plugins/install.test.ts src/gateway/server-startup-plugins.test.ts
  • PATH="/tmp/openclaw-pnpm-shim:$PATH" node scripts/check-changed.mjs
  • git diff --check

Fixes openclaw/openclaw#77959

Notes

Push note: Bryce's GitHub token lacks workflow scope, and the fork main is behind upstream by workflow-touching commits. The patch was developed and checked against current origin/main (782963ae66), then cherry-picked onto the fork's current main solely so the fork branch could be pushed without trying to create/update workflow files.

Changed files

  • src/gateway/server-startup-plugins.ts (modified, +14/-0)
  • src/plugins/install.test.ts (modified, +53/-0)
  • src/plugins/plugin-peer-link.ts (modified, +79/-0)

PR #78291: fix(plugins): repair managed npm openclaw peers

Description (problem / solution / changelog)

Summary

  • remove stale managed-root openclaw manifest, lockfile, hidden lock, installed package state, and fallback bin shims before npm plugin installs, carrying forward #78251 and #78265
  • reassert plugin-local node_modules/openclaw peer links after shared-root npm install, rollback, update, and uninstall mutations, so one plugin operation does not break already-installed SDK-using plugins
  • force safe npm commands out of inherited legacy/strict peer-dependency modes, document the managed npm peer contract, and add real npm e2e coverage for installing an old SDK-peer plugin followed by a second plugin in the same root

Fixes #77959. Supersedes #78251. Supersedes #78265. Related: #77412, #77544.

Verification

  • pnpm test src/infra/npm-managed-root.test.ts
  • pnpm test src/infra/safe-package-install.test.ts src/plugins/uninstall.test.ts src/plugins/install.npm-spec.test.ts src/plugins/install.npm-spec.e2e.test.ts src/plugins/update.test.ts src/infra/npm-managed-root.test.ts
  • git diff --check origin/main...HEAD
  • Crabbox/Testbox tbx_01kqxwfnag8bvv5aq92k8f19q9: env CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 pnpm test src/infra/safe-package-install.test.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts src/plugins/install.npm-spec.e2e.test.ts src/plugins/update.test.ts src/plugins/uninstall.test.ts

Changed files

  • CHANGELOG.md (modified, +2/-0)
  • docs/plugins/dependency-resolution.md (modified, +8/-0)
  • src/infra/npm-install-env.ts (modified, +2/-0)
  • src/infra/npm-managed-root.test.ts (modified, +135/-1)
  • src/infra/npm-managed-root.ts (modified, +176/-0)
  • src/infra/safe-package-install.test.ts (modified, +17/-0)
  • src/infra/safe-package-install.ts (modified, +2/-1)
  • src/plugins/install.npm-spec.e2e.test.ts (modified, +144/-1)
  • src/plugins/install.npm-spec.test.ts (modified, +150/-0)
  • src/plugins/install.ts (modified, +30/-2)
  • src/plugins/plugin-peer-link.ts (modified, +92/-0)
  • src/plugins/uninstall.test.ts (modified, +48/-0)
  • src/plugins/uninstall.ts (modified, +13/-0)

Code Example

lane task error:
  lane=session:agent:main:main durationMs=663
  error="Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw'
   imported from /Users/<user>/.openclaw/npm/node_modules/@openclaw/codex/dist/client-chGfNrq5.js"

---

$ ls -la ~/.openclaw/npm/node_modules/@openclaw/codex/node_modules/
total 0
drwx------  3 user  staff   96 May  5 12:15 .
drwx------  6 user  staff  192 May  4 19:45 ..
drwx------  2 user  staff   64 May  5 10:32 .bin
# NOTE: no `openclaw` symlink — peer link was never written.

---

{
  "name": "@openclaw/codex",
  "version": "2026.5.3",
  "type": "module",
  "peerDependencies": { "openclaw": ">=2026.5.3" },
  "devDependencies": { "@openclaw/plugin-sdk": "workspace:*" }
}

---

from "openclaw/plugin-sdk/agent-harness-runtime"
from "openclaw/plugin-sdk/windows-spawn"

---

ln -s /opt/homebrew/lib/node_modules/openclaw \
      ~/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

---

const hostRoot = resolveOpenClawPackageRootSync({
  argv1: process.argv[1],
  moduleUrl: import.meta.url,
  cwd: process.cwd(),
});
if (!hostRoot) {
  params.logger.warn?.(
    "Could not locate openclaw package root to symlink peerDependencies; ..."
  );
  return;
}
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails) — same packaging-regression family as #77896 (Matrix) and the cluster of closed issues #71484, #74692, #74899, #75032, #75056, #75206.

Summary

After updating to OpenClaw 2026.5.4 on a Homebrew-managed install, every main-session lane crashes immediately with ERR_MODULE_NOT_FOUND because @openclaw/[email protected] cannot resolve openclaw/plugin-sdk/* at runtime. The plugin declares peerDependencies: { "openclaw": ">=2026.5.3" } correctly, but linkOpenClawPeerDependencies() did not create the expected node_modules/openclaw symlink inside the installed plugin directory, so Node's resolver has nothing to walk to.

The result is total main-channel blackout: Telegram, Mission Control chat, and the gateway Control UI all stop receiving/sending messages even though the gateway process itself reports healthy.

Steps to reproduce

  1. Install OpenClaw 2026.5.4 via Homebrew (/opt/homebrew/lib/node_modules/openclaw).
  2. Have @openclaw/codex installed as a plugin into the default plugin npm root (~/.openclaw/npm/node_modules/@openclaw/codex, version 2026.5.3).
  3. Restart the gateway.
  4. Watch any main-session lane fail.

Expected behavior

Plugin install (or post-update reconciliation) should symlink the host openclaw package into the plugin's local node_modules/ per src/plugins/plugin-peer-link.ts → linkOpenClawPeerDependencies(). Main session lanes should boot normally.

Actual behavior

lane task error:
  lane=session:agent:main:main durationMs=663
  error="Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw'
   imported from /Users/<user>/.openclaw/npm/node_modules/@openclaw/codex/dist/client-chGfNrq5.js"

Filesystem state immediately after the failure:

$ ls -la ~/.openclaw/npm/node_modules/@openclaw/codex/node_modules/
total 0
drwx------  3 user  staff   96 May  5 12:15 .
drwx------  6 user  staff  192 May  4 19:45 ..
drwx------  2 user  staff   64 May  5 10:32 .bin
# NOTE: no `openclaw` symlink — peer link was never written.

@openclaw/[email protected] package.json (relevant slice) — peer dep IS declared:

{
  "name": "@openclaw/codex",
  "version": "2026.5.3",
  "type": "module",
  "peerDependencies": { "openclaw": ">=2026.5.3" },
  "devDependencies": { "@openclaw/plugin-sdk": "workspace:*" }
}

The codex plugin's compiled client imports the host SDK by sibling-package name, e.g.:

from "openclaw/plugin-sdk/agent-harness-runtime"
from "openclaw/plugin-sdk/windows-spawn"

…which can only resolve if openclaw is reachable from the plugin's node_modules walk. With the link missing, every import path explodes.

Local workaround

Manually creating the link that linkOpenClawPeerDependencies() was supposed to create restores everything immediately:

ln -s /opt/homebrew/lib/node_modules/openclaw \
      ~/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

(Placing the link at the npm-root level rather than per-plugin works because Node walks ancestor node_modules directories. Per-plugin under @openclaw/codex/node_modules/openclaw works equally.)

To make the workaround survive openclaw update, we re-assert the symlink at the top of our recovery-check cron and a post-upgrade-verify script. With those guards, recovery is automatic within ~5 minutes after any future regression of the same shape.

Diagnosis

Looking at src/plugins/plugin-peer-link.ts:

const hostRoot = resolveOpenClawPackageRootSync({
  argv1: process.argv[1],
  moduleUrl: import.meta.url,
  cwd: process.cwd(),
});
if (!hostRoot) {
  params.logger.warn?.(
    "Could not locate openclaw package root to symlink peerDependencies; ..."
  );
  return;
}

resolveOpenClawPackageRootSync (in src/infra/openclaw-root.ts) walks argv1, moduleUrl, and cwd ancestors looking for a package.json whose name === "openclaw". Two plausible failure modes during plugin install in a Homebrew layout:

  1. npm install runs in a child process whose argv1 is the npm CLI (not the OpenClaw binary), moduleUrl is inside npm's own dist, and cwd is the plugin npm root (~/.openclaw/npm) — none of those ancestor walks lead to /opt/homebrew/lib/node_modules/openclaw. hostRoot resolves to null, the warning is emitted, and the link is silently skipped.
  2. An earlier successful link pointed to a previous Homebrew openclaw directory that was then removed during update, leaving a dangling/missing symlink that no later step rewrites.

Either way the install-time silent skip means a healthy update can leave the system in a hard-broken state with no obvious error other than lane crashes after restart.

Suggested fixes (any one would help; combining is best)

  1. Make linkOpenClawPeerDependencies resilient to detached install contexts. When argv1/moduleUrl walks fail, fall back to:
    • the parent process's executable path,
    • npm root -g + Homebrew's /opt/homebrew/lib/node_modules,
    • an explicit OPENCLAW_HOST_ROOT env var the host can pre-set when shelling out to npm install.
  2. Promote the silent skip to a hard failure when a plugin declares peerDependencies.openclaw and the host root can't be located. Today this is a logger.warn?. that nobody sees in the wild — that's how regressions like #77896 and this one ship without anyone noticing pre-release.
  3. Re-run linkOpenClawPeerDependencies on gateway boot for every installed plugin that declares it (cheap idempotent symlink check), so the system self-heals after a Homebrew openclaw upgrade that moves/replaces the host root.
  4. Add an installer-side smoke test that, after npm install completes for a plugin with peerDependencies.openclaw, asserts the link exists and points at a real directory before declaring install success.

Environment

  • OpenClaw: 2026.5.4 (325df3e)
  • Plugin: @openclaw/[email protected]
  • Node: v25.8.2
  • OS: macOS (Apple Silicon)
  • Install method: Homebrew global (/opt/homebrew/lib/node_modules/openclaw)
  • Plugin root: ~/.openclaw/npm/node_modules/
  • Gateway port: 18789 (loopback)
  • openclaw gateway status after the fix: Connectivity probe: ok

Related

  • #77896 — same failure shape, Matrix channel, post-2026.5.4.
  • Cluster of closed issues across late April / early May 2026: #71484, #74692, #74899, #75032, #75056, #75206 — same ERR_MODULE_NOT_FOUND family.

This appears to be a recurring class bug rather than a one-off — strong candidate for the "promote silent skip to hard failure + boot-time re-link" pattern above.

extent analysis

TL;DR

The most likely fix is to modify linkOpenClawPeerDependencies to be resilient to detached install contexts and promote silent skips to hard failures.

Guidance

  1. Modify linkOpenClawPeerDependencies: Fall back to the parent process's executable path, npm root -g + Homebrew's /opt/homebrew/lib/node_modules, or an explicit OPENCLAW_HOST_ROOT env var when argv1/moduleUrl walks fail.
  2. Promote silent skip to hard failure: Change the logger.warn?. to a hard failure when a plugin declares peerDependencies.openclaw and the host root can't be located.
  3. Re-run linkOpenClawPeerDependencies on gateway boot: Run the function for every installed plugin that declares peerDependencies.openclaw to self-heal after a Homebrew openclaw upgrade.
  4. Add an installer-side smoke test: Assert the link exists and points at a real directory after npm install completes for a plugin with peerDependencies.openclaw.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a modification to the existing linkOpenClawPeerDependencies function.

Notes

The issue appears to be a recurring class bug, and addressing it will require changes to the linkOpenClawPeerDependencies function and potentially adding additional error handling and testing.

Recommendation

Apply the workaround of manually creating the link and then modify linkOpenClawPeerDependencies to be resilient to detached install contexts and promote silent skips to hard failures. This will ensure that the system self-heals after a Homebrew openclaw upgrade and prevents similar regressions in the future.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Plugin install (or post-update reconciliation) should symlink the host openclaw package into the plugin's local node_modules/ per src/plugins/plugin-peer-link.ts → linkOpenClawPeerDependencies(). Main session lanes should boot normally.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: @openclaw/codex peerDependency link not created on install — gateway lanes crash with ERR_MODULE_NOT_FOUND for openclaw/plugin-sdk/* [2 pull requests, 1 comments, 2 participants]