From ebe59a987fd5ceba4821713d85befee193a67d47 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 18 Mar 2026 15:55:23 -0400 Subject: [PATCH] fix: use shell: true for LSP spawn on Windows to resolve .cmd executables (#1233) On Windows, executables like npx, tsc, and typescript-language-server are .cmd batch scripts. Node.js's spawn() can't find them without shell: true because it looks for exact binary names, not .cmd wrappers. This caused ENOENT crashes during auto-mode when the LSP tried to spawn npx tsc --noEmit for TypeScript diagnostics. Added shell: true conditional on process.platform === 'win32' in the LSP client's spawn call. Unix platforms are unaffected. Fixes #1222 --- packages/pi-coding-agent/src/core/lsp/client.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/pi-coding-agent/src/core/lsp/client.ts b/packages/pi-coding-agent/src/core/lsp/client.ts index 8f31afbe5..d9b53088e 100644 --- a/packages/pi-coding-agent/src/core/lsp/client.ts +++ b/packages/pi-coding-agent/src/core/lsp/client.ts @@ -455,6 +455,9 @@ async function getOrCreateClientOnce(config: ServerConfig, cwd: string, initTime cwd, stdio: ["pipe", "pipe", "pipe"], env: env ? { ...process.env, ...env } : undefined, + // On Windows, executables like npx/tsc are .cmd scripts that need + // shell resolution. Without this, spawn fails with ENOENT (#1222). + shell: process.platform === "win32", }); // Handle spawn failure (e.g., ENOENT when the command doesn't exist).