Skip to content

fix: fall back to cmd.exe when PowerShell unavailable on Windows (#11960)#12917

Open
ChenXin-2009 wants to merge 2 commits into
continuedev:mainfrom
ChenXin-2009:fix-terminal-spawn-unknown
Open

fix: fall back to cmd.exe when PowerShell unavailable on Windows (#11960)#12917
ChenXin-2009 wants to merge 2 commits into
continuedev:mainfrom
ChenXin-2009:fix-terminal-spawn-unknown

Conversation

@ChenXin-2009

@ChenXin-2009 ChenXin-2009 commented Jun 29, 2026

Copy link
Copy Markdown

Description

Fixes #11960

On Windows,
un_terminal_command\ always uses \child_process.spawn('powershell.exe', ...)\ to run terminal commands. When PowerShell is unavailable due to corporate security policy (or any other reason), this fails with \spawn UNKNOWN.

Changes

  • \core/tools/implementations/runTerminalCommand.ts: Added \isPowerShellAvailable()\ check that probes for \powershell.exe\ using \execFileSync. When not found, falls back to %COMSPEC%\ (typically \cmd.exe) with /C\ argument, which is always available on Windows.

All three spawn paths (streaming, non-streaming, background/detached) benefit from this fix since they all go through \getShellCommand().


Summary by cubic

On Windows, fall back to cmd.exe when PowerShell is unavailable to avoid “spawn UNKNOWN” and keep terminal commands working in restricted environments.

  • Bug Fixes
    • Added cached isPowerShellAvailable() using execFileSync to probe powershell.exe once, avoiding repeated 3s checks.
    • Updated getShellCommand() to use %COMSPEC% (defaults to cmd.exe) with /C when PowerShell is missing; affects streaming, non-streaming, and detached spawns.

Written for commit 89d3d31. Summary will update on new commits.

Review in cubic

@ChenXin-2009 ChenXin-2009 requested a review from a team as a code owner June 29, 2026 12:10
@ChenXin-2009 ChenXin-2009 requested review from sestinj and removed request for a team June 29, 2026 12:10
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 29, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread core/tools/implementations/runTerminalCommand.ts
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run_terminal_command fails with "spawn UNKNOWN" on Windows CMD environment

1 participant