fix(daemon): prefer current node (process.execPath) and add macOS version manager paths to service PATH

On macOS, `openclaw gateway install` hardcodes the system node
(/opt/homebrew/bin/node) in the launchd plist, ignoring the node from
version managers (fnm/nvm/volta). This causes the Gateway to run a
different node version than the user's shell environment.

Two fixes:

1. `resolvePreferredNodePath` now checks `process.execPath` first.
   If the currently running node is a supported version, use it directly.
   This respects the user's active version manager selection.

2. `buildMinimalServicePath` now includes version manager bin directories
   on macOS (fnm, nvm, volta, pnpm, bun), matching the existing Linux
   behavior.

Fixes #18090
Related: #6061, #6064
This commit is contained in:
Yao
2026-02-16 22:03:53 +08:00
committed by Peter Steinberger
parent 59eac34c2b
commit 1a8548df18
4 changed files with 188 additions and 11 deletions

View File

@@ -152,10 +152,24 @@ export async function resolvePreferredNodePath(params: {
runtime?: string;
platform?: NodeJS.Platform;
execFile?: ExecFileAsync;
execPath?: string;
}): Promise<string | undefined> {
if (params.runtime !== "node") {
return undefined;
}
// Prefer the node that is currently running `openclaw gateway install`.
// This respects the user's active version manager (fnm/nvm/volta/etc.).
const currentExecPath = params.execPath ?? process.execPath;
if (currentExecPath) {
const execFileImpl = params.execFile ?? execFileAsync;
const version = await resolveNodeVersion(currentExecPath, execFileImpl);
if (isSupportedNodeVersion(version)) {
return currentExecPath;
}
}
// Fall back to system node.
const systemNode = await resolveSystemNodeInfo(params);
if (!systemNode?.supported) {
return undefined;