fix(ide/process-utils): spawn powershell.exe with -NoProfile -NonInteractive - #27241
fix(ide/process-utils): spawn powershell.exe with -NoProfile -NonInteractive#27241kaluchi wants to merge 1 commit into
Conversation
…ractive Switch to execFile with explicit argv to match the -NoProfile pattern used by every other powershell call site in the repo.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request standardizes how PowerShell is invoked within the Windows IDE process probe. By switching to Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the reliability and security of PowerShell command execution on Windows by switching from exec to execFile in the core package. Specifically, getProcessTableWindows now utilizes execFileAsync with the -NoProfile and -NonInteractive flags to ensure a clean and consistent execution environment. The unit tests in process-utils.test.ts have been updated to validate this new implementation, including a new test case that explicitly checks for the presence of the required PowerShell flags. I have no feedback to provide.
|
@scidomino and here independent lttle addition to #27247 (request autoclosed by github) |
|
still requires merge |
Summary
Spawns
powershell.exeviaexecFilewith-NoProfile -NonInteractiveflags in the Windows IDE process probe (
getProcessTableWindows). Thiswas the only PowerShell call site in the repo invoked without
-NoProfile— every other site (security.ts,clipboardUtils.ts,secure-browser-launcher.ts,parsePowerShellCommandDetails,gemma/platform.ts) already uses this pattern.Why this matters
Removes a profile-load side effect and speeds up startup.
Every other powershell call site in gemini-cli already uses
-NoProfile. Users and agents don't expect a persistent PowerShellsession across spawns — this probe was the lone exception.
A user's
$PROFILEcan contain anything. In some setups it mutatesthe shared conhost via
chcpor[Console]::OutputEncoding. Thatleaks into gemini-cli's encoding behavior and gets stuck for the rest
of the session — the
chcpsnapshot is cached process-wide ingetCachedEncodingForBuffer(packages/core/src/utils/systemEncoding.ts)and is reused for every shell-output
TextDecoderinshellExecutionService.ts(cpSpawn path and PTY path).Change
execAsync(\"powershell \\\"...\\\"\", opts)withexecFileAsync(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", powershellCommand], opts).execFile(vs.exec) drops the unnecessarycmd.exehop and the shell-string interpolation surface.maxBufferand JSON parsing unchanged.Tests
Existing
process-utils.test.tsassertions updated to the new(program, argsArray)mock signature. Added one explicit test thatverifies
-NoProfile,-NonInteractive, and-Commandare present inthe args.
Context
Found while investigating the broader Windows encoding issues tracked in
#20968. This change is independent of that — it removes a side-effect
that complicates the encoding picture without itself fixing the
underlying decoder behavior.