codex - 💡(How to fix) Fix Codex App for Windows shows different environment variables between the integrated terminal and the agent shell_command runner. [8 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19546Fetched 2026-04-26 05:15:23
View on GitHub
Comments
8
Participants
3
Timeline
18
Reactions
0
Author
Timeline (top)
commented ×8labeled ×4mentioned ×2subscribed ×2
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

The issue can be fixed by ensuring environment variable keys are case-insensitive or by modifying the agent shell_command runner to handle 'Path' and 'PATH' variables correctly.

Guidance

  • The discrepancy in environment variables between the integrated terminal and the agent shell_command runner is causing the MSBuild failure.
  • Verify that the agent shell_command runner is correctly configured to handle case-insensitive environment variable keys.
  • Consider modifying the PowerShell script to handle both 'Path' and 'PATH' variables, ensuring that only one is passed to the MSBuild process.
  • Investigate the Codex App configuration to see if there's an option to synchronize environment variables between the integrated terminal and the agent shell_command runner.

Example

# Example PowerShell script to handle both 'Path' and 'PATH' variables
$envVars = [Environment]::GetEnvironmentVariables('Process')
$pathValue = $envVars['Path']
if ($null -eq $pathValue) {
    $pathValue = $envVars['PATH']
}
# Use $pathValue in the MSBuild process

Notes

The provided solution assumes that the issue is related to the case-sensitivity of environment variable keys. However, without further information about the Codex App and its configuration, this is only a potential workaround.

Recommendation

Apply workaround: The provided example script can be used as a temporary solution to handle the environment variable discrepancy until a more permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING