Skip to content

Commit 0f67a45

Browse files
Long Chen (from Dev Box)Copilot
andcommitted
fix: inject Node.js bin dir into ACP child process PATH on Windows
ACP child processes spawn .cmd batch scripts (e.g. claude-agent-acp.cmd) that internally invoke node.exe. When the host process PATH does not include the Node.js installation directory, the child fails with 'node is not recognized as an internal or external command'. Fix: prepend process.execPath's directory to the spawned env PATH, with Windows-safe case-insensitive key lookup (Path vs PATH). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0aa0876 commit 0f67a45

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/adapters/AcpAdapter.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,18 @@ export class AcpAdapter implements AgentAdapter {
308308
this.validateExecutable();
309309
const env = { ...process.env, ...extraEnv };
310310
this.sanitizeSpawnEnv(env);
311+
312+
// Ensure Node.js bin directory is in PATH so child .cmd scripts can find `node`
313+
const nodeBinDir = path.dirname(process.execPath);
314+
const pathKey = process.platform === 'win32'
315+
? Object.keys(env).find(k => k.toUpperCase() === 'PATH') || 'Path'
316+
: 'PATH';
317+
const currentPath = env[pathKey] || '';
318+
if (!currentPath.split(path.delimiter).some(p => p.toLowerCase() === nodeBinDir.toLowerCase())) {
319+
env[pathKey] = `${nodeBinDir}${path.delimiter}${currentPath}`;
320+
debugLog('[AcpAdapter]', `Injected Node.js bin dir into PATH: ${nodeBinDir}`);
321+
}
322+
311323
const args = [...this.defaultArgs];
312324

313325
debugLog('[AcpAdapter]', `Spawning: ${this.executable} ${args.join(' ')}`);

0 commit comments

Comments
 (0)