fix: prefer PowerShell 7 over legacy Windows PowerShell 5.1 - #13365
Merged
Conversation
marius-kilocode
marked this pull request as ready for review
August 24, 2026 13:16
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (12 files)
Fix these issues in Kilo Cloud Reviewed by grok-4.6 · Input: 148.5K · Output: 17.7K · Cached: 542.6K Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
August 24, 2026 13:32
| export const probe = (env: NodeJS.ProcessEnv = process.env) => | ||
| locations(env).filter((file) => statSync(file, { throwIfNoEntry: false })?.isFile()) | ||
|
|
||
| export const pwsh = (env: NodeJS.ProcessEnv = process.env) => which("pwsh", env) ?? probe(env)[0] |
There was a problem hiding this comment.
not a big deal, neither a blocker, rather a FYI, nowadays it'd be probe(env).at(0) to avoid "messing" with arrays (because if the length is 0 it would access an undefined index)
WebReflection
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kilo Code on Windows keeps selecting Windows PowerShell 5.1 for agent command execution even when PowerShell 7 is installed (#13324). PS 5.1 writes UTF-16LE with a BOM for
Out-File/>redirection and has other encoding differences, so agent-driven commands can corrupt files that pwsh would leave intact.Root cause, from the current selection logic:
Shell.preferred()/Shell.acceptable()inpackages/core/src/shell.tsresolve pwsh only via PATH lookup. When thekilo serveprocess inherits a PATH without the pwsh directory (common with Store installs whose alias lives under%LOCALAPPDATA%\Microsoft\WindowsApps), detection silently degrades toSystem32\WindowsPowerShell\v1.0\powershell.exe.vscode.env.shellbut only forwards it to the webview for display; the CLI shell selection never sees it.Plan on this branch:
packages/core/test/kilocode/powershell.test.tsassert that with pwsh stripped from PATH, an installed PowerShell 7 still wins over legacy 5.1. They are expected to fail on the Windows CI shard until the fix commit lands.%ProgramFiles%\PowerShell\7,%ProgramFiles(x86)%\PowerShell\7,%LOCALAPPDATA%\Microsoft\WindowsApps) after PATH lookup fails, keep explicitshellconfig as the highest-priority override, and switch the hardcoded call sites to prefer pwsh when present.Refs #13324