Skip to content

pwsh.exe hardcoded in 6 places - CLI completely unusable on Windows 11 with only PowerShell 5.1 (closed #411 is still broken in v0.0.417) #1680

@guidegdm

Description

@guidegdm

Describe the bug

Issue #411 was closed as "not_planned" in Oct 2025, but the bug is still present and getting worse — it now blocks the CLI from running any shell command at all on Windows machines that ship only with Windows PowerShell 5.1 (powershell.exe).

The error on every single command:

<exited with error: PowerShell 6+ (pwsh) is not available. Please install it from https://aka.ms/powershell (https://aka.ms/powershell). Error: Error: Command failed: pwsh.exe --version 'pwsh.exe' is not recognized as an internal or external command, operable program or file.

Affected version

0.0.417 (also reproducible on 0.0.415, 0.0.414 — any recent version)

Root cause (with exact locations in index.js)

pwsh.exe is hardcoded in 6 places in ~/.copilot/pkg/universal/{version}/index.js.
All 6 must be changed to powershell.exe for the CLI to work on Windows PowerShell 5.1:

# Pattern Location
1 process.platform==="win32"?"pwsh.exe":"pwsh" Shell type detection
(xds function)
2 l?"pwsh.exe":"bash" PTY spawn (class constructor)
3 Start-Process -FilePath "pwsh.exe"
tryExecuteDetachedCommandWindows (inner PS command)
4 ths("pwsh.exe",["-NoProfile","-Command",I]
tryExecuteDetachedCommandWindows (outer spawn)
5 "pwsh.exe --version" ensureShellIsSupported version check
6 (one remaining — likely in installer/zip extraction path) TBD

Proposed fix

Use powershell.exe as the fallback when pwsh.exe is not found:

// Before
process.platform === "win32" ? "pwsh.exe" : "pwsh"

// After — detect what's available
process.platform === "win32" ? (hasExe("pwsh.exe") ? "pwsh.exe" :
"powershell.exe") : "pwsh"

Or simpler: just use powershell.exe (works on both PS 5.1 and PS 7+, both ship  
it).

Why "not_planned" is the wrong call

- Windows 11 ships only with powershell.exe by default. No pwsh.
- powershell.exe is available on every Windows machine going back to Windows 7.
- The CLI already works perfectly once patched  there is no functional dependency on PS 6+.
- This blocks 100% of Windows users on default installs from using the CLI at all.
- Related open issue: #1086

Workaround (until fixed)

Patch ~/.copilot/pkg/universal/{version}/index.js  replace all pwsh.exe  powershell.exe. 
Must be re-applied after each winget upgrade GitHub.Copilot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions