Repository navigation
Work around Copilot mutating extension host process env variables that break SwiftPM - #6084
Conversation
…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
There was a problem hiding this comment.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Otherwise it won't get the new workaround.
The copilot SDK package (
@github/copilot) used by the Copilot extension mutatesprocess.envto restrict git settings:This breaks Swift Package Manager which uses bare repositories, because our spawned
flutterprocess (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
toolEnvbecause 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.