← Back to PRs

#22406: Fix update detection for Companion App npm-prefix installs

by graysurf open 2026-02-21 04:03 View on GitHub →
size: S
# 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