Codex App for Windows shows different environment variables between the integrated terminal and the agent shell_command runner.
What version of the Codex App are you using (From “About Codex” dialog)?
26.422.30944
What subscription do you have?
Plus
What platform is your computer?
Windows
What issue are you seeing?
Codex App for Windows shows different environment variables between the integrated terminal and the agent shell_command runner.
Integrated terminal:
[Environment]::GetEnvironmentVariables('Process').GetEnumerator() |
Where-Object { $_.Key -ceq 'Path' -or $_.Key -ceq 'PATH' } |
ForEach-Object { $_.Key }
Output:
Path
Agent shell_command runner output:
Path
PATH
Impact:
MSBuild fails before compilation with:
MSB6001: Invalid command line switch for "CL.exe".
System.ArgumentException: Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'
What steps can reproduce the bug?
Codex App for Windows shows different environment variables between the integrated terminal and the agent shell_command runner.
Integrated terminal:
[Environment]::GetEnvironmentVariables('Process').GetEnumerator() |
Where-Object { $_.Key -ceq 'Path' -or $_.Key -ceq 'PATH' } |
ForEach-Object { $_.Key }
Output:
Path
Agent shell_command runner output:
Path
PATH
Impact:
MSBuild fails before compilation with:
MSB6001: Invalid command line switch for "CL.exe".
System.ArgumentException: Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'
What is the expected behavior?
_No response_
Additional information
Bug report id: a8b57032-ceca-48a9-b203-f953fdd1a6bd
10 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This is not a duplicate!!!!!!
@Tomer96 maybe it's unrelated, but I just opened a ticket that may solve your problem: https://github.com/openai/codex/issues/19550
If you're using Powershell (and the agent as well) and Powershell was installed through Winget or Microsoft Store, the agent struggles with certain tool calls and seems to be unable to run certain commands for pnpm or node among others. I noticed that when I uninstalled Powershell 7 and then reinstalled it using a MSI installer, both the install location and path were set correctly and the tool calls stopped failing.
It might be worth checking to see if you have Powershell installed in C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.1.0_x64__{some_version} or if you have it installed in C:\Program Files\PowerShell\7
If you have the WindowsApps version, just uninstall it and download the MSI package from Microsoft and install that.
@SlippyDong Hello.
I do not have the MS version of PWSH. I have the latest pwsh released install from the official repo: https://github.com/PowerShell/PowerShell/releases/tag/v7.6.1 (specific PowerShell-7.6.1-win-x64.msi)
This is a fuckup in the Codex app for Windows for sure 100%.
It's important to note that this issue is observed only with the Codex app for Windows. The Codex extension for VS Code or the Codex CLI does NOT have such issues with double path injection; they use a normalized Path.
<img width="1224" height="1172" alt="Image" src="https://github.com/user-attachments/assets/eec6fd5a-5a38-4f72-8b14-2aa7ee322b67" />
needed to add a dedicated rule under AGENTS.md so the model can start listening.
with-clean-path.ps1
Ah, sorry, I did not notice this distinction. I never used Codex app itself. Are there any benefits over using the IDE extension?
I've been using Codex CLI, Codex IDE extension, and now the Codex App extensively over the past year, and I think the correct answer for the current state of the Codex app is absolutely no. The app is not yet as stable and robust as I would like it to be.
I can reproduce this on a newer Codex Desktop build as well.
Environment observed:
OpenAI.Codex_26.602.3474.0_x64__2p2nqsd0c76g0codex.exe app-server --analytics-default-enabled%USERPROFILE%\.codex\.sandbox-bin\codex-command-runner-0.137.0-alpha.4.exeObserved in the agent shell command environment:
prints both entries in the same process environment:
The values are effectively identical. This causes PowerShell environment enumeration to fail:
with:
I also checked the persisted Windows environment sources:
Both only show
Path, not a separate uppercasePATH, so the duplicate appears to be introduced while Codex constructs the child process environment.Parent process chain observed for the shell command:
Relevant detail: Codex launches shell commands with
powershell.exe -NoProfile -Command ..., so a PowerShell profile workaround cannot reliably fix this for agent shell commands.Suggested fix: when constructing child environments on Windows, normalize keys case-insensitively and emit exactly one canonical
Pathentry instead of passing bothPATHandPath.try
path=i.e lowercase path