From fca9f0c1068171e90581afbfe8e8ad2a0bc5e89e Mon Sep 17 00:00:00 2001 From: Alexander Farber Date: Sun, 25 Jan 2026 14:01:32 +0100 Subject: [PATCH 1/5] Use PowerShell Get-Command for Windows sandbox detection --- scripts/sandbox_command.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/sandbox_command.js b/scripts/sandbox_command.js index 1ab36ca3c..f3fb495ab 100644 --- a/scripts/sandbox_command.js +++ b/scripts/sandbox_command.js @@ -70,19 +70,25 @@ if (!geminiSandbox) { geminiSandbox = (geminiSandbox || '').toLowerCase(); const commandExists = (cmd) => { - const checkCommand = os.platform() === 'win32' ? 'where' : 'command -v'; + if (os.platform() === 'win32') { + // Use PowerShell's Get-Command for reliable detection on Windows + // This works in both cmd.exe and PowerShell environments + try { + execSync( + `powershell -NoProfile -Command "Get-Command ${cmd} -ErrorAction SilentlyContinue"`, + { stdio: 'ignore' }, + ); + return true; + } catch { + return false; + } + } + + // Unix-like systems use 'command -v' try { - execSync(`${checkCommand} ${cmd}`, { stdio: 'ignore' }); + execSync(`command -v ${cmd}`, { stdio: 'ignore' }); return true; } catch { - if (os.platform() === 'win32') { - try { - execSync(`${checkCommand} ${cmd}.exe`, { stdio: 'ignore' }); - return true; - } catch { - return false; - } - } return false; } }; From efbec0451ca9a08fb6a00bf5f05ec3a425558087 Mon Sep 17 00:00:00 2001 From: DennisYu07 <617072224@qq.com> Date: Fri, 6 Feb 2026 03:27:07 -0800 Subject: [PATCH 2/5] fix error for powershell comand --- scripts/sandbox_command.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sandbox_command.js b/scripts/sandbox_command.js index f3fb495ab..a7ce4bfc2 100644 --- a/scripts/sandbox_command.js +++ b/scripts/sandbox_command.js @@ -75,7 +75,7 @@ const commandExists = (cmd) => { // This works in both cmd.exe and PowerShell environments try { execSync( - `powershell -NoProfile -Command "Get-Command ${cmd} -ErrorAction SilentlyContinue"`, + `powershell -NoProfile -Command "if (Get-Command ${cmd} -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"`, { stdio: 'ignore' }, ); return true; From 8755042509f48491d05397b9bb323acc808aa318 Mon Sep 17 00:00:00 2001 From: DennisYu07 <617072224@qq.com> Date: Sun, 8 Feb 2026 05:45:49 -0800 Subject: [PATCH 3/5] add null judge for cmd --- scripts/sandbox_command.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/sandbox_command.js b/scripts/sandbox_command.js index a7ce4bfc2..e52f43161 100644 --- a/scripts/sandbox_command.js +++ b/scripts/sandbox_command.js @@ -70,6 +70,10 @@ if (!geminiSandbox) { geminiSandbox = (geminiSandbox || '').toLowerCase(); const commandExists = (cmd) => { + if (!cmd) { + return false; + } + if (os.platform() === 'win32') { // Use PowerShell's Get-Command for reliable detection on Windows // This works in both cmd.exe and PowerShell environments From 396d53367b69e1149eeb8229f368a4523ec9bde6 Mon Sep 17 00:00:00 2001 From: DennisYu07 <617072224@qq.com> Date: Sun, 8 Feb 2026 06:13:34 -0800 Subject: [PATCH 4/5] Fix: use where.exe instead of PowerShell Get-Command for Windows command detection Co-authored-by: Qwen-Coder --- scripts/sandbox_command.js | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/scripts/sandbox_command.js b/scripts/sandbox_command.js index e52f43161..479a3a2bf 100644 --- a/scripts/sandbox_command.js +++ b/scripts/sandbox_command.js @@ -70,29 +70,19 @@ if (!geminiSandbox) { geminiSandbox = (geminiSandbox || '').toLowerCase(); const commandExists = (cmd) => { - if (!cmd) { - return false; - } - - if (os.platform() === 'win32') { - // Use PowerShell's Get-Command for reliable detection on Windows - // This works in both cmd.exe and PowerShell environments - try { - execSync( - `powershell -NoProfile -Command "if (Get-Command ${cmd} -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"`, - { stdio: 'ignore' }, - ); - return true; - } catch { - return false; - } - } - - // Unix-like systems use 'command -v' + const checkCommand = os.platform() === 'win32' ? 'where.exe' : 'command -v'; try { - execSync(`command -v ${cmd}`, { stdio: 'ignore' }); + execSync(`${checkCommand} ${cmd}`, { stdio: 'ignore' }); return true; } catch { + if (os.platform() === 'win32' && !cmd.endsWith('.exe')) { + try { + execSync(`${checkCommand} ${cmd}.exe`, { stdio: 'ignore' }); + return true; + } catch { + return false; + } + } return false; } }; From 5ec3b755e2be573f830a7ae0d08ea790d1e1f477 Mon Sep 17 00:00:00 2001 From: Alexander Farber Date: Sun, 8 Feb 2026 16:10:48 +0100 Subject: [PATCH 5/5] Add a comment to explain where.exe --- scripts/sandbox_command.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/sandbox_command.js b/scripts/sandbox_command.js index 479a3a2bf..75cc4127a 100644 --- a/scripts/sandbox_command.js +++ b/scripts/sandbox_command.js @@ -70,6 +70,8 @@ if (!geminiSandbox) { geminiSandbox = (geminiSandbox || '').toLowerCase(); const commandExists = (cmd) => { + // Use 'where.exe' (not 'where') on Windows because PowerShell aliases + // 'where' to 'Where-Object', which breaks command detection. const checkCommand = os.platform() === 'win32' ? 'where.exe' : 'command -v'; try { execSync(`${checkCommand} ${cmd}`, { stdio: 'ignore' });