openclaw - 💡(How to fix) Fix Matrix channel: staging rename fails with ENOTEMPTY on every gateway boot (Linux + Windows variants) [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#72330Fetched 2026-04-27 05:31:28
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
closed ×1commented ×1subscribed ×1

The bundled matrix channel cannot complete its staging step on a fresh install. Every gateway boot logs the same error and the channel never starts:

[channels] failed to load bundled channel matrix: ENOTEMPTY: directory not empty,
  rename '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/.plugin-matrix-XXXXXX/plugin'
       -> '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/matrix'

The destination extensions/matrix/ already contains files from an earlier staging step (or a prior boot), and Linux rename(2) on a non-empty directory returns ENOTEMPTY. The matrix plugin then fails to register and the channel never connects to a homeserver.

Error Message

The bundled matrix channel cannot complete its staging step on a fresh install. Every gateway boot logs the same error and the channel never starts: 4. Inspect log: every boot prints the ENOTEMPTY rename error for the matrix channel

Root Cause

The bundled matrix channel cannot complete its staging step on a fresh install. Every gateway boot logs the same error and the channel never starts:

[channels] failed to load bundled channel matrix: ENOTEMPTY: directory not empty,
  rename '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/.plugin-matrix-XXXXXX/plugin'
       -> '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/matrix'

The destination extensions/matrix/ already contains files from an earlier staging step (or a prior boot), and Linux rename(2) on a non-empty directory returns ENOTEMPTY. The matrix plugin then fails to register and the channel never connects to a homeserver.

Fix Action

Fix / Workaround

Workarounds attempted (none successful for the staging issue)

  • rm -rf of dist/extensions/matrix/ and .plugin-matrix-* directories — gateway recreates partial content on next boot, then fails the same rename
  • openclaw doctor --fix — completes successfully (Plugins panel shows Loaded: 65, Errors: 0) but the next gateway boot still fails the matrix staging
  • Manual cp -r .plugin-matrix-XXX/plugin extensions/matrix — the staging directory is cleaned up before this can run reliably
  • Downgrade to 2026.4.25-beta.7 — different timing but same ENOTEMPTY pattern

Code Example

[channels] failed to load bundled channel matrix: ENOTEMPTY: directory not empty,
  rename '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/.plugin-matrix-XXXXXX/plugin'
       -> '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/matrix'

---

[plugins] matrix: crypto runtime bootstrap failed: Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'
RAW_BUFFERClick to expand / collapse

Summary

The bundled matrix channel cannot complete its staging step on a fresh install. Every gateway boot logs the same error and the channel never starts:

[channels] failed to load bundled channel matrix: ENOTEMPTY: directory not empty,
  rename '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/.plugin-matrix-XXXXXX/plugin'
       -> '/root/.openclaw/plugin-runtime-deps/openclaw-2026.4.24-XXXXXXXXXXXX/dist/extensions/matrix'

The destination extensions/matrix/ already contains files from an earlier staging step (or a prior boot), and Linux rename(2) on a non-empty directory returns ENOTEMPTY. The matrix plugin then fails to register and the channel never connects to a homeserver.

Environment

  • OpenClaw 2026.4.24 and 2026.4.25-beta.7 (both reproduce)
  • Node v22.22.2 (NodeSource), npm 10.9.7 and 10.4.0
  • Ubuntu 24.04 LTS in WSL2 on Windows 11; running as root
  • Native Windows installation hits adjacent staging bugs that look like the same family:
    • Cannot find module 'C:\Users\…\node_modules\zod\index.cjs' for the mattermost plugin
    • Only URLs with a scheme in: file, data, and node are supported … Received protocol 'c:' (matrix channel ESM dynamic-import of bare C:\...\plugin\index.js)

Reproduction

  1. npm install -g openclaw on Ubuntu 24.04
  2. ~/.openclaw/openclaw.json configured with a matrix channel (homeserver / userId / accessToken)
  3. Run gateway via systemd: systemctl start openclaw-gateway
  4. Inspect log: every boot prints the ENOTEMPTY rename error for the matrix channel

Adjacent issue: native crypto binding not fetched

@matrix-org/matrix-sdk-crypto-nodejs ships a download-lib.js postinstall that fetches the platform-specific binary (matrix-sdk-crypto.linux-x64-gnu.node). The bundled-deps installer appears to use npm install --ignore-scripts, so the binding is never downloaded, and the matrix plugin fails crypto bootstrap with:

[plugins] matrix: crypto runtime bootstrap failed: Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs-linux-x64-gnu'

Manually running node download-lib.js inside the package directory resolves this.

Workarounds attempted (none successful for the staging issue)

  • rm -rf of dist/extensions/matrix/ and .plugin-matrix-* directories — gateway recreates partial content on next boot, then fails the same rename
  • openclaw doctor --fix — completes successfully (Plugins panel shows Loaded: 65, Errors: 0) but the next gateway boot still fails the matrix staging
  • Manual cp -r .plugin-matrix-XXX/plugin extensions/matrix — the staging directory is cleaned up before this can run reliably
  • Downgrade to 2026.4.25-beta.7 — different timing but same ENOTEMPTY pattern

Suggested fix

The staging code that does rename(stagingDir, finalDir) should first fs.rmSync(finalDir, { recursive: true, force: true }) (or use fs.cpSync with { force: true, recursive: true } instead of rename). The current rename approach is incompatible with Linux semantics when finalDir already exists with content.

Related: bonjour watchdog kill loop

Likely a separate issue: under WSL2 NAT, the bonjour mDNS announce never reaches state=announced, the bonjour-plugin watchdog logs non-announced service; attempting re-advertise, and the gateway receives SIGTERM in the same second. This causes a 30-60 second restart loop. Renaming dist/extensions/bonjour/ removes this specific trigger but a separate ~60-second SIGTERM still fires from somewhere (possibly tied to the kill-tree-*.js module visible in dist/). Happy to file separately if useful.

extent analysis

TL;DR

The most likely fix for the staging issue is to modify the staging code to remove the destination directory before renaming, using fs.rmSync or fs.cpSync with recursive and force options.

Guidance

  • Verify that the issue is indeed caused by the rename operation failing due to a non-empty destination directory by checking the error message and the directory contents.
  • Consider using fs.rmSync(finalDir, { recursive: true, force: true }) before the rename operation to ensure the destination directory is empty.
  • Alternatively, use fs.cpSync with { force: true, recursive: true } instead of rename to copy the contents of the staging directory to the final directory, overwriting any existing files.
  • Additionally, investigate the adjacent issue with the native crypto binding not being fetched and consider running node download-lib.js manually or modifying the installer to run this script.

Example

const fs = require('fs');
const path = require('path');

// Before renaming
fs.rmSync(finalDir, { recursive: true, force: true });

// Then rename
fs.renameSync(stagingDir, finalDir);

Notes

The suggested fix assumes that the staging code has access to the fs module and can modify the directory structure. Additionally, the issue with the bonjour watchdog kill loop may be a separate issue and should be investigated further.

Recommendation

Apply the workaround by modifying the staging code to use fs.rmSync or fs.cpSync with recursive and force options, as this is the most direct solution to the staging issue.

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…

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 - 💡(How to fix) Fix Matrix channel: staging rename fails with ENOTEMPTY on every gateway boot (Linux + Windows variants) [1 comments, 2 participants]