Skip to content

fix(openclaw): record correct installPath for native-package installs / Mac homebrew (v4.12.7)#39

Merged
FRIDAY-Drakon merged 1 commit intomainfrom
fix/native-package-install-path
Apr 25, 2026
Merged

fix(openclaw): record correct installPath for native-package installs / Mac homebrew (v4.12.7)#39
FRIDAY-Drakon merged 1 commit intomainfrom
fix/native-package-install-path

Conversation

@FRIDAY-Drakon
Copy link
Copy Markdown

Summary

Closes the v4.12.3–v4.12.6 Mac regression. Reproduced on Friday/mikes-mac on every release: `shieldcortex install` succeeded, plugin landed on disk, hooks installed, but `shieldcortex doctor` kept flagging `.plugins.installs/entries/allow["shieldcortex-realtime"]` as orphans. Linux fleet hosts never hit it.

Root cause

`installPlugin()`'s native-package code path (the one that fires when npm-global lives in OpenClaw's search path β€” `/opt/homebrew/lib/node_modules` on Mac) recorded the WRONG `installPath` in `openclaw.json`:

```text
path.dirname(path.dirname(globalPluginPath)) ← package root (wrong)
path.dirname(globalPluginPath) ← dist dir (right β€” manifest's parent)
```

The `trusted-local-copy` code path used the correct convention; only native-package was off. `detectInstallState()` checked `installPath/openclaw.plugin.json`, found nothing (manifest is in `dist/`), and returned `pluginInstalled = false` β†’ false-positive orphans every time.

Fix

  • `src/setup/openclaw.ts` β€” native-package branch now passes `pluginDir = path.dirname(globalPluginPath)` to `trustLocalPlugin`. Same value is logged to the user as is recorded in config.
  • `src/setup/deep-clean.ts` β€” `detectInstallState()` now also checks `installPath/dist/openclaw.plugin.json` as a fallback. Fleet hosts that already have the bad `installPath` written from v4.12.3–v4.12.6 stop false-flagging on the next doctor run, even before they re-install.

Tests

  • `src/tests/deep-clean.test.ts` β€” new "honours installPath/dist fallback" test reproduces the Friday scenario with the wrong-path config and asserts `pluginInstalled = true`, `orphanCount = 0`.
  • `src/tests/openclaw-install-path.test.ts` (new file, 3 cases) β€” locks in that the writer passes `pluginDir` to `trustLocalPlugin`, never the double-dirname pattern, and the logged path matches the recorded path.

54/54 release-track tests green.

Verification on Mac after upgrade

```bash
npm install -g shieldcortex@4.12.7
shieldcortex openclaw install
shieldcortex doctor # should show "OpenClaw residue: clean (plugin + hook installed, config aligned)"
```

The defensive `installPath/dist` fallback means the doctor will report clean immediately after upgrading, without needing to re-run `openclaw install` first.

πŸ€– Generated with Claude Code

… (Mac homebrew)

False-positive doctor "orphans" on every Mac install since v4.12.3.
Reproduced on Friday/mikes-mac on every release v4.12.3 β†’ v4.12.6.

Root cause: installPlugin()'s native-package code path (the one that
fires when npm-global lives in OpenClaw's search path β€” i.e.
/opt/homebrew/lib/node_modules on Mac) recorded the WRONG installPath
in openclaw.json:

  path.dirname(path.dirname(globalPluginPath))   ← package root  (wrong)
  path.dirname(globalPluginPath)                 ← dist dir      (right)

The trusted-local-copy code path used the correct convention; only
native-package was off. detectInstallState() checked
`installPath/openclaw.plugin.json`, found nothing (manifest is in
dist/), and returned pluginInstalled=false β†’ false-positive orphans.

Fix:

- src/setup/openclaw.ts: native-package branch now passes
  `pluginDir = path.dirname(globalPluginPath)` to trustLocalPlugin.
  Matches the convention used by every other code path. Same value
  is logged to the user as is recorded in config.
- src/setup/deep-clean.ts: detectInstallState now also checks
  `installPath/dist/openclaw.plugin.json` as a fallback β€” fleet hosts
  with the bad installPath stop false-flagging on next doctor run,
  even before they re-install.

4 new tests (1 in deep-clean, 3 in new openclaw-install-path file).
54/54 release-track tests green.

Bumps to v4.12.7 across root pkg, plugin pkg, plugin manifest, lockfile.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@FRIDAY-Drakon FRIDAY-Drakon merged commit 676512a into main Apr 25, 2026
2 checks passed
@FRIDAY-Drakon FRIDAY-Drakon deleted the fix/native-package-install-path branch April 25, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants