Windows: Codex 0.123.0 injects both PATH and Path into the shell environment, breaking PowerShell Env provider and causing intermittent shell startup failures
What version of Codex CLI is running?
codex-cli 0.123.0
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5.4
What platform is your computer?
Microsoft Windows x64
What terminal emulator and version are you using (if applicable)?
Codex Desktop app on Windows, with the npm-installed codex also on PATH
What issue are you seeing?
On Windows, Codex appears to construct a malformed process environment for shell execution by injecting both PATH and Path into the same process environment block.
Because Windows environment variables are case-insensitive, PowerShell's Env: provider treats this as a duplicate-key collision and fails with:
Get-ChildItem : An item with the same key has already been added.
In earlier threads on the same machine, this also correlated with Codex shell startup failures before command execution, including:
Internal Windows PowerShell error. Loading managed Windows PowerShell failed with error 8009001d.
So the root problem here appears to be malformed Windows env var merging in Codex, not a repo-specific issue.
What steps can reproduce the bug?
In a Codex Windows session:
- Confirm the installed CLI version:
``powershell`
codex --version
`
Observed:
text``
codex-cli 0.123.0
- Confirm the npm package version:
``powershell`
npm list -g @openai/codex --depth=0
`
Observed:
text``
@openai/codex@0.123.0
- Inspect the effective process environment from within the Codex shell context:
``powershell`
cmd /c "set PATH & set Path"
PATH=
Observed: both and Path=` are present in the same process environment.
- Try enumerating the PowerShell env provider:
``powershell`
Get-ChildItem Env:
`
Observed:
text``
Get-ChildItem : An item with the same key has already been added.
- Compare against the actual Windows environment sources:
``powershell`
reg query "HKCU\Environment"
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
Path
Observed: only exists in the registry sources, not a separate uppercase PATH`.
What is the expected behavior?
Codex should normalize Windows environment variables case-insensitively before spawning the shell.
Expected behavior:
- only one canonical
Pathentry should be present in the spawned process environment Get-ChildItem Env:should succeed normally- shell startup should not intermittently fail due to malformed env state
What do you see instead?
Codex spawns a shell environment that includes both PATH and Path, which breaks PowerShell env enumeration and appears to contribute to intermittent shell startup failures.
Additional information
Concrete local evidence:
where codexresolves the npm global install first:C:\Users\hnili\AppData\Roaming\npm\codex- In the Codex shell process, both
PATHandPathare present. - In
HKCU\EnvironmentandHKLM\...\Environment, onlyPathexists. - So the duplicate is being introduced during Codex environment construction, not inherited directly from Windows registry state.
This looks distinct from the broader 8009001d symptom reports because it provides a narrower repro and a likely root cause.
Possibly related:
- #19100
- #13917
- #14057
- #18465
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗