Skip to content

fix(ide/process-utils): spawn powershell.exe with -NoProfile -NonInteractive - #27241

Closed
kaluchi wants to merge 1 commit into
google-gemini:mainfrom
kaluchi:fix/process-utils-no-profile
Closed

fix(ide/process-utils): spawn powershell.exe with -NoProfile -NonInteractive#27241
kaluchi wants to merge 1 commit into
google-gemini:mainfrom
kaluchi:fix/process-utils-no-profile

Conversation

@kaluchi

@kaluchi kaluchi commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Spawns powershell.exe via execFile with -NoProfile -NonInteractive
flags in the Windows IDE process probe (getProcessTableWindows). This
was 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.

  1. Every other powershell call site in gemini-cli already uses
    -NoProfile. Users and agents don't expect a persistent PowerShell
    session across spawns — this probe was the lone exception.

  2. A user's $PROFILE can contain anything. In some setups it mutates
    the shared conhost via chcp or [Console]::OutputEncoding. That
    leaks into gemini-cli's encoding behavior and gets stuck for the rest
    of the session — the chcp snapshot is cached process-wide in
    getCachedEncodingForBuffer (packages/core/src/utils/systemEncoding.ts)
    and is reused for every shell-output TextDecoder in
    shellExecutionService.ts (cpSpawn path and PTY path).

Change

  • Replace execAsync(\"powershell \\\"...\\\"\", opts) with execFileAsync(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", powershellCommand], opts).
  • execFile (vs. exec) drops the unnecessary cmd.exe hop and the shell-string interpolation surface.
  • maxBuffer and JSON parsing unchanged.

Tests

Existing process-utils.test.ts assertions updated to the new
(program, argsArray) mock signature. Added one explicit test that
verifies -NoProfile, -NonInteractive, and -Command are present in
the 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.

…ractive

Switch to execFile with explicit argv to match the -NoProfile pattern
used by every other powershell call site in the repo.
@kaluchi
kaluchi requested a review from a team as a code owner May 19, 2026 04:01
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 execFileAsync and explicitly passing -NoProfile and -NonInteractive, the change eliminates potential side effects caused by user-defined PowerShell profiles and improves the reliability of process data retrieval.

Highlights

  • PowerShell Execution Improvement: Updated the Windows process probe to use execFileAsync with powershell.exe instead of execAsync, ensuring consistent use of -NoProfile and -NonInteractive flags.
  • Performance and Stability: Prevents side effects from user PowerShell profiles and removes unnecessary shell-string interpolation, leading to faster startup and more predictable encoding behavior.
  • Test Coverage: Updated existing tests to reflect the new argument structure and added a new test case to verify the presence of required PowerShell flags.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

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.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels May 19, 2026
@kaluchi

kaluchi commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

@scidomino and here independent lttle addition to #27247 (request autoclosed by github)

@kaluchi

kaluchi commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

still requires merge

@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants