External: github/copilot-sdk
Problem
CopilotClientOptions.Environment silently clears and replaces the child process environment rather than merging with the inherited environment. Decompiled from GitHub.Copilot.SDK v0.2.0:
if (options.Environment != null)
{
processStartInfo.Environment.Clear();
foreach (var (key, value) in options.Environment)
{
processStartInfo.Environment[key] = value;
}
}
Any embedder that sets Environment to augment PATH (the obvious use case — MAUI apps don't inherit terminal PATH) will unknowingly strip critical platform variables (COMSPEC, SystemRoot, TEMP, LOCALAPPDATA, etc.) from the CLI child process.
On Windows this breaks ConPTY shell spawning entirely — the CLI's PowerShell tool fails with File not found: (empty path) because ConPTY can't resolve the shell executable without these env vars.
Expected behavior
Either:
- Merge
options.Environment with the inherited environment (set/override only the specified keys), or
- Document clearly that
Environment is a full replacement and embedders must copy Environment.GetEnvironmentVariables() first
Workaround
Copy the full system environment before augmenting:
var env = new Dictionary<string, string>(
OperatingSystem.IsWindows() ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables())
{
if (entry.Key is string key && entry.Value is string val)
env[key] = val;
}
// Now augment PATH, HOME, etc.
options.Environment = env;
PolyPilot fix
PR #439
External: github/copilot-sdk
Problem
CopilotClientOptions.Environmentsilently clears and replaces the child process environment rather than merging with the inherited environment. Decompiled fromGitHub.Copilot.SDKv0.2.0:Any embedder that sets
Environmentto augment PATH (the obvious use case — MAUI apps don't inherit terminal PATH) will unknowingly strip critical platform variables (COMSPEC,SystemRoot,TEMP,LOCALAPPDATA, etc.) from the CLI child process.On Windows this breaks ConPTY shell spawning entirely — the CLI's PowerShell tool fails with
File not found:(empty path) because ConPTY can't resolve the shell executable without these env vars.Expected behavior
Either:
options.Environmentwith the inherited environment (set/override only the specified keys), orEnvironmentis a full replacement and embedders must copyEnvironment.GetEnvironmentVariables()firstWorkaround
Copy the full system environment before augmenting:
PolyPilot fix
PR #439