Browse Source

fix: skip shell wrapper for .exe files in canExecute on Windows

spawnSync with shell:true passes unquoted paths to cmd.exe, which fails when the path contains spaces (e.g. 'C:\Program Files\...\opencode.exe'). .exe files are native executables that do not need a shell, so only enable shell:true for .cmd/.bat/.ps1 shims that require it.
Zhanyuanium 2 weeks ago
parent
commit
dc51242eac
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/cli/system.ts

+ 1 - 1
src/cli/system.ts

@@ -61,7 +61,7 @@ function canExecute(
       env: environment,
       // Required on Windows to execute .cmd/.bat shims produced by npm/pnpm/yarn
       // (Node's CVE-2024-27980 patch blocks them without a shell).
-      shell: isWindows,
+      shell: isWindows && !/\.exe$/i.test(command),
     });
     return result.status === 0;
   } catch {