Skip to content

Work around Copilot mutating extension host process env variables that break SwiftPM - #6084

Merged
DanTup merged 2 commits into
masterfrom
work-around-copilot-env-mutation
Jun 11, 2026
Merged

DanTup merged 2 commits into
masterfrom
work-around-copilot-env-mutation

Conversation

@DanTup

@DanTup DanTup commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

The copilot SDK package (@github/copilot) used by the Copilot extension mutates process.env to restrict git settings:

GIT_CONFIG_COUNT=<n+1>
GIT_CONFIG_KEY_<n>=safe.bareRepository
GIT_CONFIG_VALUE_<n>=explicit

This breaks Swift Package Manager which uses bare repositories, because our spawned flutter process (which uses the package manager) inherits those variables.

Until this is fixed (github/copilot-cli#3602, microsoft/vscode#320880) we should detect this and reduce the count to prevent the setting from applying to our spawned processes.

We only make changes if the last value is exactly what we expect, to avoid undoing any other settings (for ex. that the user may have set). This means we must do this per-invocation and not in the cached toolEnv because it's possible we would first cache before Copilot has mutated the env vars.

Fixes #6074
Fixes #6083
Fixes flutter/flutter#187828

Will merge this to main first, then cherry-pick into 3.136.1.

…t break SwictPM

The copilot SDK package (`@github/copilot`) used by the Copilot extension mutates `process.env` to restrict git settings:

```
GIT_CONFIG_COUNT=<n+1>
GIT_CONFIG_KEY_<n>=safe.bareRepository
GIT_CONFIG_VALUE_<n>=explicit
```

This breaks Swift Package Manager which uses bare repositories, because our spawned `flutter` process (which uses the package manager) inherits those variables.

Until this is fixed (github/copilot-cli#3602, microsoft/vscode#320880) we should detect this and reduce the count to prevent the setting from applying to our spawned processes.

We only make changes if the last value is exactly what we expect, to avoid undoing any other settings (for ex. that the user may have set). This means we must do this per-invocation and not in the cached `toolEnv` because it's possible we would first cache before Copilot has mutated the env vars.

Fixes #6074
Fixes #6083
@DanTup DanTup added this to the v3.136.1 milestone Jun 11, 2026
@DanTup DanTup added is bug fix in flutter Relates to running Flutter apps labels Jun 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 introduces a workaround for a GitHub Copilot environment variable mutation issue (specifically safe.bareRepository=explicit) by adding the getFixedToolEnvForCopilotMutation utility function and integrating it into getToolEnv(), along with comprehensive unit tests. However, a high-severity issue was identified where safeToolSpawn directly accesses the toolEnv global variable instead of calling getToolEnv(), which bypasses this workaround for spawned tool processes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/extension/utils/processes.ts
@codecov

codecov Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.08%. Comparing base (bb25897) to head (624fbd5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6084      +/-   ##
==========================================
+ Coverage   71.06%   71.08%   +0.02%     
==========================================
  Files         172      172              
  Lines       13031    13042      +11     
  Branches     2604     2607       +3     
==========================================
+ Hits         9260     9271      +11     
  Misses       3276     3276              
  Partials      495      495              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Otherwise it won't get the new workaround.
@DanTup
DanTup merged commit 59933a3 into master Jun 11, 2026
25 checks passed
@DanTup
DanTup deleted the work-around-copilot-env-mutation branch June 11, 2026 13:05
DanTup added a commit that referenced this pull request Aug 13, 2026
…bles that break SwictPM"

This reverts commit 9c477ee.

Fixes #6084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in flutter Relates to running Flutter apps is bug fix

Projects

None yet

1 participant