#22406: Fix update detection for Companion App npm-prefix installs
size: S
Cluster:
Update Handling Fixes
# Fix update detection for Companion App npm-prefix installs
## Problem Summary
`openclaw update` can return `not-git-install` for Companion App installs even when `openclaw status` correctly reports an npm-managed package update path.
## Expected vs Actual
- Expected: `openclaw update` detects Companion App npm-prefix installs (for example `~/.openclaw/lib/node_modules/openclaw`) and runs the package-manager update flow.
- Actual: `openclaw update` skips with "package manager couldn't be detected".
## Impact
- Blocks the standard update flow for Companion App users.
- Forces manual fallback commands instead of the documented `openclaw update` path.
## Reproduction
1. Install OpenClaw via Companion App (npm-prefix layout under `~/.openclaw`).
2. Run `openclaw status` and confirm it reports npm update availability.
3. Run `openclaw update`.
4. Observe skip reason `not-git-install`.
## Issues Found
| ID | Severity | Confidence | Status | Description |
|---|---|---|---|---|
| PR-22406-BUG-01 | medium | high | fixed | `runGatewayUpdate` only accepted strict global-root equality and missed Companion npm-prefix layouts. |
## Fix Approach
- Added Companion-prefix detection in `src/infra/update-global.ts`:
- Recognizes package roots shaped like `<prefix>/lib/node_modules/openclaw` where `<prefix>` is `.openclaw`.
- Resolves a managed npm executable (`<prefix>/tools/node/bin/npm` or `<prefix>/bin/npm`) when available.
- Extended `globalInstallArgs` to optionally include:
- explicit npm executable path,
- explicit `--prefix` for npm/pnpm commands.
- Updated `runGatewayUpdate` (`src/infra/update-runner.ts`) to:
- keep existing strict global-root detection first,
- fall back to Companion-prefix detection when strict detection fails,
- run the update command with explicit prefix/executable for this fallback path.
- Added regression coverage in `src/infra/update-runner.test.ts` for Companion-prefix fallback behavior.
## Testing Results
- ✅ `pnpm test src/infra/update-runner.test.ts`
- ✅ `pnpm build`
- ⚠️ `pnpm check` fails due to a pre-existing unrelated type error:
- `src/memory/qmd-manager.test.ts(1225,22): TS2741 Property 'get' is missing in type '{ all: () => never; }'`
Closes #20008
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds fallback detection for Companion App npm-prefix installs when standard global manager detection fails. The implementation correctly chains detection methods (strict global root first, then companion-prefix fallback) and passes explicit `--prefix` and npm executable paths to handle the non-standard installation layout (`~/.openclaw/lib/node_modules/openclaw`).
<h3>Confidence Score: 4/5</h3>
- Safe to merge with minor considerations around edge cases.
- The implementation is well-structured with proper fallback logic, path validation, and test coverage. The companion-prefix detection is appropriately conservative (checks exact path structure and `.openclaw` basename). The pnpm `--prefix` code path appears to be unreachable in practice since companion installs are npm-only, but this doesn't cause issues. No critical bugs detected.
- No files require special attention.
<sub>Last reviewed commit: 96533ce</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
83.2%
#18961: fix: detect pnpm package manager in openclaw update
by norci · 2026-02-17
82.9%
#8600: fix(update): add --ignore-scripts to prevent supply chain attacks
by yubrew · 2026-02-04
80.3%
#15475: fix(update): Handle Homebrew+Node Cellar path mismatch
by brandonwise · 2026-02-13
79.5%
#12804: fix(daemon): use wrapper script for pnpm global installs in service...
by odinho · 2026-02-09
79.2%
#17815: fix: use $HOME as cwd for global update to prevent path-dedot panic
by frankekn · 2026-02-16
77.9%
#20585: fix: pre-flight ownership check before global update
by mwfj · 2026-02-19
77.6%
#19801: fix: pre-check write permissions before global install to prevent E...
by menhguin · 2026-02-18
77.4%
#6064: fix(daemon): prefer bundled node from install-cli.sh over system node
by joyshmitz · 2026-02-01
77.2%
#23730: fix(update): correctly compare versions with -N build suffix
by mrx-arafat · 2026-02-22
75.9%