← Back to PRs

#17113: Windows: prefer PowerShell 7 (pwsh) in shell resolution

by wnsdud-jy open 2026-02-15 12:29 View on GitHub →
agents size: XS
## Summary On modern Windows setups, PowerShell 7 (`pwsh`) is commonly installed alongside Windows PowerShell 5.1 but not selected by default. This PR updates Windows shell resolution to prefer PowerShell 7. Resolution order: ```text 1. COMSPEC when it points to pwsh.exe 2. C:\Program Files\PowerShell\7\pwsh.exe 3. Windows PowerShell 5.1 (System32\WindowsPowerShell\v1.0\powershell.exe) 4. Final fallback: powershell.exe ``` - Keep `getShellConfig()` on `win32` aligned with this resolver. - Update Windows assertion in `src/agents/shell-utils.e2e.test.ts` to accept either `powershell` or `pwsh`. ## Validation - `lsp_diagnostics` clean on modified files. - `pnpm test:e2e src/agents/shell-utils.e2e.test.ts` passes. ## Scope This PR intentionally avoids generic PATH-based `pwsh` discovery to keep the change scoped to the original issue. Closes #9629 <!-- greptile_comment --> <h3>Greptile Summary</h3> Updates Windows shell resolution to prefer PowerShell 7 (`pwsh.exe`) over Windows PowerShell 5.1 (`powershell.exe`). The new resolution order checks COMSPEC for pwsh.exe first, then looks for PowerShell 7 at the standard installation path (`C:\Program Files\PowerShell\7\pwsh.exe`), and falls back to Windows PowerShell 5.1 if neither is found. **Key changes:** - Modified `resolvePowerShellPath()` to prioritize PowerShell 7 detection - Updated Windows test assertion to accept either `powershell` or `pwsh` in the shell path - Maintains backward compatibility with Windows PowerShell 5.1 fallback The implementation correctly handles quoted COMSPEC paths and uses proper file existence checks before returning paths. Test coverage appropriately reflects the new behavior. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are narrow in scope, well-tested, and implement a straightforward priority order for shell resolution. The logic properly handles edge cases (quoted paths, missing installations) with appropriate fallbacks. No breaking changes or security concerns identified. - No files require special attention <sub>Last reviewed commit: bafe326</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs