From 66d3555a1108854c2dc0fc90e91bf44c4a825763 Mon Sep 17 00:00:00 2001 From: Luis del Toro Date: Sun, 5 Apr 2026 17:21:28 +0200 Subject: [PATCH] Prefer which node over process.execPath to find out node path --- bin/cli.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index d7cdf8c..342886f 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -232,14 +232,19 @@ function ensureDir(p) { function resolveNodePath() { if (process.env.OPENCODE_BROWSER_NODE) return process.env.OPENCODE_BROWSER_NODE; - if (process.execPath && /node(\.exe)?$/.test(process.execPath)) return process.execPath; + // Prefer `which node` / `where node` — returns stable symlink paths (e.g. + // /opt/homebrew/bin/node) rather than versioned paths (e.g. + // /opt/homebrew/Cellar/node/25.8.1/bin/node) that break on package manager + // upgrades (Homebrew, nvm, fnm, volta, etc.). try { const command = isWindows() ? "where node" : "which node"; const output = execSync(command, { stdio: ["ignore", "pipe", "ignore"] }) .toString("utf8") .trim(); if (output) return output; - } catch {} + } catch { + if (process.execPath && /node(\.exe)?$/.test(process.execPath)) return process.execPath; + } return process.execPath; }