Skip to content

[Bug]: openclaw plugins install/update on 2026.7.1 hits ENOTDIR scandir on openclaw.json after stale install path is removed #107467

Closed

Description

@Valkster70

Environment

Summary

After openclaw plugins update @openclaw/<external-plugin> fails to write its install record cleanly on 2026.7.1, attempting any follow-up install --force, uninstall, or even registry --refresh aborts with:

[openclaw] Could not start the CLI.
[openclaw] Reason: ENOTDIR: not a directory, scandir '/home/<user>/.openclaw/openclaw.json'

The CLI is calling scandir() on the openclaw.json file as if it were a directory, which predictably fails. The bug renders the plugin uninstallable/installable until manual cleanup of stale state.

Steps to reproduce

  1. Have a healthy @openclaw/<external-plugin> plugin installed (Tavily used here; pattern reproduces on any npm-installed official external plugin).
  2. Run openclaw plugins update @openclaw/<external-plugin>@2026.7.1. The CLI claims success (Updated tavily: 2026.6.11 -> 2026.7.1) but a NEW project dir appears at ~/.openclaw/npm/projects/<name>-<hash>__openclaw-generation__g-<newhash>/ while the OLD project dir at ~/.openclaw/npm/projects/<name>-<hash>/ is left untouched. installed_plugin_index in SQLite accumulates BOTH records.
  3. Run openclaw plugins registry --refresh. CLI exits with the ENOTDIR error. Plugin registry still shows the old version, gateway continues to load the old install path.
  4. rm -rf ~/.openclaw/npm/projects/<name>-<hash>/ (clean up the stale OLD project dir manually).
  5. Run openclaw plugins install @openclaw/<external-plugin>@2026.7.1 --force. CLI aborts with ENOTDIR before writing the new install record.
  6. Run openclaw plugins uninstall <plugin>. CLI aborts with ENOTDIR. (uninstall without --force requires an interactive TTY and errors in non-TTY SSH.)
  7. Symlink the OLD path to the NEW path: ln -s <newhash-dir> <hash-dir>. Registry refresh still drops the plugin ("not installed"). Plugin is now completely untracked and cannot be re-registered.
  8. The interactive openclaw gateway install wizard hits the same ENOTDIR on the Tavily install step.

Expected

Plugin install/update should either write the install record successfully (and replace any stale install path silently), or fail loudly with a clear message specifically about plugin install state. The CLI should tolerate rm -rf'd stale install paths gracefully on subsequent operations.

Actual

CLI exits with ENOTDIR: not a directory, scandir '/home/<user>/.openclaw/openclaw.json' for every install/update/uninstall/registry-refresh operation once a stale install path is removed.

Error output

$ openclaw plugins install @openclaw/tavily-plugin@2026.7.1 --force
Installing @openclaw/tavily-plugin@2026.7.1 into /home/<user>/.openclaw/npm/projects/openclaw-tavily-plugin-<hash>__openclaw-generation__g-<newhash>…
Plugin manifest id "tavily" differs from npm package name "@openclaw/tavily-plugin"; using manifest id as the config key.
[openclaw] Could not start the CLI.
[openclaw] Reason: ENOTDIR: not a directory, scandir '/home/<user>/.openclaw/openclaw.json'
[openclaw] Debug: set OPENCLAW_DEBUG=1 to include the stack trace.
[openclaw] Try: openclaw doctor
[openclaw] Help: openclaw --help

Workarounds attempted (none work)

  • openclaw plugins registry --refresh (re-reads stale path; no recovery)
  • openclaw plugins install --force (still hits ENOTDIR)
  • openclaw plugins uninstall <plugin> (needs interactive TTY; fails in non-TTY SSH)
  • openclaw doctor --fix (does not repair this state; reports drift but offers no actionable recovery)
  • Symlinking the OLD path to the NEW generation dir (registry refresh still drops the plugin)
  • chattr +i was toggled off and back on; reproduction is unaffected by config protection

Workarounds that work (interim)

  • Leave the plugin un-installed; gateway falls back to other configured providers (Ollama search, etc.).
  • Manual edit of installed_plugin_index (the SQLite row's install_records_json JSON column) to point at the new install path — viable but not documented or supported.

Related

Activity

  1. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 14, 2026, 12:27 PM ET / 16:27 UTC.

    Summary
    Keep open: this is a credible cross-platform v2026.7.1 regression that blocks all plugin lifecycle operations and setup after managed npm install metadata drifts; current main still propagates ENOTDIR from the managed-project scan, and no merged fix or release provenance establishes that the reported recovery failure is resolved.

    Reproducibility: yes. for the shipped regression path: the report provides repeatable Ubuntu and macOS steps, and current source contains the matching uncaught ENOTDIR scan path. A destructive current-main live reproduction and stack trace have not yet been captured.

    Next step
    The regression is concrete and bounded enough for one repair PR, but implementation must first capture the current-main stack and verify whether ENOTDIR is the root defect or a symptom of corrupted path provenance.

    Review details

    Best possible solution:

    Make the managed npm update transaction replace the authoritative install record only after the new generation validates, clean obsolete generations after commit, and let openclaw doctor --fix plus a visible setup Fix action reconcile stale or missing paths without manual SQLite editing.

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

    Yes for the shipped regression path: the report provides repeatable Ubuntu and macOS steps, and current source contains the matching uncaught ENOTDIR scan path. A destructive current-main live reproduction and stack trace have not yet been captured.

    Is this the best way to solve the issue?

    Yes, a bounded repair of managed npm path derivation, atomic install-index replacement, stale-generation cleanup, and Doctor recovery is the narrowest maintainable solution; swallowing ENOTDIR alone would not be sufficient.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact reason the managed-project scan resolves to openclaw.json is not yet proven from a current-main stack trace; fixing only the ENOTDIR catch could mask a deeper state/config path derivation defect.
    • The report describes duplicate SQLite install records and stale generation roots, so recovery must prove atomic record replacement and safe cleanup rather than merely allowing the command to continue.

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

    Label changes

    Label changes:

    • add P0: A routine shipped plugin update can leave plugin management and the interactive setup flow unusable, with recovery requiring manual filesystem or SQLite surgery.
    • add impact:data-loss: The reported update accumulates conflicting persisted install records and can leave the plugin untracked after stale-path cleanup.
    • add impact:ux-release-blocker: Plugin setup and recovery are blocked with no working in-product repair path; the successful workaround requires unsupported manual SQLite editing.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P0: A routine shipped plugin update can leave plugin management and the interactive setup flow unusable, with recovery requiring manual filesystem or SQLite surgery.
    • impact:data-loss: The reported update accumulates conflicting persisted install records and can leave the plugin untracked after stale-path cleanup.
    • impact:ux-release-blocker: Plugin setup and recovery are blocked with no working in-product repair path; the successful workaround requires unsupported manual SQLite editing.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/plugins/install.test.ts
    • node scripts/run-vitest.mjs src/plugins/install-paths.test.ts
    • node scripts/run-vitest.mjs src/commands/doctor
    • node scripts/check-changed.mjs -- src/plugins/install.ts src/plugins/install-paths.ts src/infra/npm-managed-root.ts src/commands/doctor

    What I checked:

    • Current source failure path: The managed npm package-directory scan calls fs.readdir(projectsDir), handles ENOENT only, and rethrows ENOTDIR; this matches the reported fatal error class rather than treating a malformed or stale path as recoverable state. (src/plugins/install.ts, 6f0326af3642)
    • Managed path ownership: Managed npm project paths are derived beneath the configured state directory's npm/projects tree, so scandir resolving to openclaw.json indicates a path-provenance or persisted-record invariant that needs a stack trace and regression coverage rather than reporter-side cleanup. (src/plugins/install-paths.ts, 6f0326af3642)
    • Persisted install contract: Current documentation defines the SQLite installed_plugin_index as the durable source for install records, including broken or missing manifests, and says uninstall removes both persisted records and tracked managed directories. Public docs: docs/cli/plugins.md. (docs/cli/plugins.md:415, 6f0326af3642)
    • Expected repair contract: Current documentation describes registry refresh and openclaw doctor --fix as repair paths for persisted registry and managed npm drift, while the report shows both paths becoming unreachable or ineffective in this state. Public docs: docs/cli/plugins.md. (docs/cli/plugins.md:477, 6f0326af3642)
    • Product direction: VISION.md prioritizes bug fixes, stability, setup reliability, and first-run UX; repairing a shipped plugin lifecycle regression fits those priorities directly. (VISION.md:2, 6f0326af3642)
    • Release boundary: The report reproduces on shipped release v2026.7.1 at 2d2ddc4, while no matching fix commit or later shipped release was established during review. (CHANGELOG.md, 2d2ddc43d0dc)

    Likely related people:

    • vincentkoc: Recent merged and release-noted work repeatedly touches managed plugin npm installation, repair, lifecycle cleanup, and registry behavior, making this the strongest routing signal for the affected boundary. (role: recent area contributor; confidence: high; files: src/plugins/install.ts, src/plugins/install-paths.ts, src/infra/npm-managed-root.ts)
    • shakkernerd: Recent release history credits work on preserving managed npm peer dependencies during plugin installs and updates, adjacent to the generation-root and rollback behavior implicated here. (role: adjacent area contributor; confidence: medium; files: src/infra/npm-managed-root.ts, src/plugins/install.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.
  2. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    no-staleExclude from stale automation
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jul 14, 2026
  3. self-assigned this
    on Jul 16, 2026
  4. added a commit that references this issue on Jul 16, 2026
    804de49
  5. added a commit that references this issue on Jul 17, 2026
    5738a43
  6. locked as resolved and limited conversation to collaborators on Sep 5, 2026
  7. added a commit that references this issue on Sep 11, 2026
    64ff140
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:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.no-staleExclude from stale automation

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions