From 3c0708b749f9f41c3ac696ca24be183280da388f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Santos?= Date: Tue, 30 Dec 2025 21:38:14 +0200 Subject: [PATCH] fix(windows): resolve EINVAL error when opening worktree in VS Code (#434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit execFile doesn't search PATH on Windows, causing batch files like code.cmd to fail with EINVAL. Use spawn with shell: true for Windows batch file commands (.cmd, .bat) to allow PATH resolution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com> --- .../main/ipc-handlers/task/worktree-handlers.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts b/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts index bf3cc636..a3d7fa78 100644 --- a/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts @@ -977,6 +977,20 @@ async function openInIDE(dirPath: string, ide: SupportedIDE, customPath?: string } } + // Special handling for Windows batch files (.cmd, .bat) + // execFile doesn't search PATH, so we need shell: true for batch files + if (platform === 'win32' && (command.endsWith('.cmd') || command.endsWith('.bat'))) { + return new Promise((resolve) => { + const child = spawn(command, [dirPath], { + shell: true, + detached: true, + stdio: 'ignore' + }); + child.unref(); + resolve({ success: true }); + }); + } + // Use command line tool with execFileAsync await execFileAsync(command, [dirPath]); return { success: true };