From 85642bbb6d46f5bc3b992e72b69a4c4ab643f486 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 18 Mar 2026 10:21:33 -0400 Subject: [PATCH] fix(lsp): use where.exe on Windows to resolve command paths (#1134) --- packages/pi-coding-agent/src/core/lsp/lspmux.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/pi-coding-agent/src/core/lsp/lspmux.ts b/packages/pi-coding-agent/src/core/lsp/lspmux.ts index 13e5c84ec..0e9f6e638 100644 --- a/packages/pi-coding-agent/src/core/lsp/lspmux.ts +++ b/packages/pi-coding-agent/src/core/lsp/lspmux.ts @@ -49,7 +49,16 @@ const DEFAULT_SUPPORTED_SERVERS = new Set([ function which(command: string): string | null { try { - return execSync(`which ${command}`, { encoding: "utf-8" }).trim() || null; + // On Windows, prefer `where.exe` over `which` — MSYS/Git Bash's `which` + // returns POSIX paths (/c/Users/...) that Node's spawn() can't execute (#1121). + const isWindows = process.platform === "win32"; + const cmd = isWindows ? "where.exe" : "which"; + const result = isWindows + ? execSync(`${cmd} ${command}`, { encoding: "utf-8" }) + : execSync(`which ${command}`, { encoding: "utf-8" }); + // `where.exe` may return multiple lines — take the first + const resolved = result.trim().split(/\r?\n/)[0]?.trim(); + return resolved || null; } catch { return null; }