Skip to content

Commit b3ff5d1

Browse files
committed
fix: unify node/npm binary paths across platforms with symlinks
On macOS/Linux, downloadNodejs() now creates symlinks from nodejs/node and nodejs/npm to nodejs/bin/node and nodejs/bin/npm, matching Windows where they're already in the root. PATH setup includes node_modules/.bin/ for agent binaries on all platforms.
1 parent abecc48 commit b3ff5d1

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

packages/launcher/src/main/agent-manager.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ class AgentManager {
308308
}
309309
// Don't attempt if Node.js isn't installed yet
310310
const portableNodeDir = path.join(os.homedir(), '.openagents', 'nodejs');
311-
const nodeBin = path.join(portableNodeDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
312-
if (!fs.existsSync(nodeBin)) return;
311+
// Check both unified path (symlink) and legacy platform-specific path
312+
const nodeBin = path.join(portableNodeDir, 'node' + (process.platform === 'win32' ? '.exe' : ''));
313+
const nodeBinLegacy = path.join(portableNodeDir, 'bin', 'node');
314+
if (!fs.existsSync(nodeBin) && !fs.existsSync(nodeBinLegacy)) return;
313315

314316
return this._startDaemon();
315317
}
@@ -340,12 +342,14 @@ class AgentManager {
340342
const { spawn } = require('child_process');
341343
const portableNodeDir = path.join(os.homedir(), '.openagents', 'nodejs');
342344

343-
// Build enhanced PATH with portable Node.js
344-
const extraDirs = [portableNodeDir];
345+
// Build enhanced PATH with portable Node.js and agent binaries
346+
const extraDirs = [
347+
path.join(portableNodeDir, 'node_modules', '.bin'), // agent binaries
348+
portableNodeDir, // node, npm (unified via symlinks)
349+
path.join(portableNodeDir, 'bin'), // legacy macOS/Linux node, npm
350+
];
345351
if (process.platform === 'win32') {
346352
extraDirs.push(path.join(process.env.APPDATA || '', 'npm'));
347-
} else {
348-
extraDirs.push(path.join(portableNodeDir, 'bin'));
349353
}
350354
const enhancedPath = [...extraDirs, process.env.PATH || ''].join(path.delimiter);
351355

packages/launcher/src/main/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ async function downloadNodejs(nodejsDir, onProgress) {
146146
const flag = ext === 'tar.gz' ? '-xzf' : '-xJf';
147147
execSync(`tar ${flag} "${tarPath}" -C "${nodejsDir}" --strip-components=1`, { timeout: 120000 });
148148
try { fs.unlinkSync(tarPath); } catch {}
149+
150+
// Unify paths with Windows: create symlinks in root so node/npm are at
151+
// ~/.openagents/nodejs/node and ~/.openagents/nodejs/npm (same as Windows)
152+
const binDir = path.join(nodejsDir, 'bin');
153+
for (const name of ['node', 'npm', 'npx']) {
154+
const src = path.join(binDir, name);
155+
const dest = path.join(nodejsDir, name);
156+
if (fs.existsSync(src) && !fs.existsSync(dest)) {
157+
try { fs.symlinkSync(src, dest); } catch {}
158+
}
159+
}
149160
}
150161

151162
if (onProgress) onProgress(100, 'Done');

0 commit comments

Comments
 (0)