Codex Desktop injects both Path and PATH into command environment on Windows, breaking MSBuild/Roslyn

Open 💬 2 comments Opened Mar 21, 2026 by yuenchiusouk

Summary
On Windows, Codex Desktop launches shell commands with both Path and PATH environment variables present in the same process. Normal PowerShell on the same machine only has Path. This causes .NET/MSBuild/Roslyn builds to fail with duplicate-key environment handling errors.

Environment

OS: Windows 11
Codex Desktop version: OpenAI.Codex_26.313.5234.0_x64
Shell used by Codex: cmd / pwsh
Project type affected: ASP.NET WebForms / MSBuild / Roslyn build
Steps to reproduce

Open Codex Desktop on Windows.
Run:
cmd /c set | findstr /r /c:"^PATH=" /c:"^Path="
Observe that both PATH= and Path= are present.
Run an MSBuild-based .NET build in Codex Desktop.
Observe build failure.
Expected result

Only one path environment variable should exist in the child process, effectively Path.
Actual result

Codex command processes contain both Path and PATH.
MSBuild/Roslyn fails with:
error MSB3883: Unexpected exception
Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'
Control comparison

In normal Windows PowerShell outside Codex Desktop:
Get-ChildItem Env: | Where-Object { $_.Name -match '^(?i)path$' }
only shows Path.
The same SFInsurance.csproj build succeeds outside Codex Desktop.
Extra detail

Inside Codex, PATH appears to include an extra prepended C:\Program Files\PowerShell\7, while Path contains the normal inherited Windows value.
The process chain observed in Codex includes codex-command-runner.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗