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
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I think this is confusing the shit out of 5.5 on 0.124 too, things like gh issue view don't work (401 Try authenticating with: gh auth login), and with full permissions enabled nothing works (same error), but when it asks for permissions to ie check stuff in via gh, those commands work fine without any weird path/auth issues.
I'd really prefer that gh continues working normally and that you don't funnel codex into using the damned git app, which has more issues than gh itself and I will not be reporting bugs for other than that I can't seem to disable it or make it stop trying to use it.
Same Issue. This also breaks
vstest.console.exeI can reproduce the same root cause in current Codex Desktop on Windows, with an additional deterministic downstream failure in
pnpm exec.Environment:
Inside a fresh Codex task:
The Windows user and machine environment sources contain only one
Path, so the duplicate is introduced in the Codex-spawned environment.A deterministic consequence:
pnpm binreports the correct projectnode_modules\.binpnpm exec eslint --versionandpnpm exec vitest --versionfail because the local commands are not found.cmdshims and direct Node entry points workpnpm run lintworksThis matches Node's documented Windows behavior: when an
envobject contains case variants such asPATHandPath, only the first case-insensitive match after sorting is passed to the child process. pnpm addsnode_modules\.binto one variant, while the child process receives the other.Normalizing the process environment to a single
Pathimmediately before invoking pnpm makespnpm exec, lint, typecheck, and tests pass consistently.I also tried using Codex
shell_environment_policyto exclude inherited PATH and explicitly set onePath, then fully restarted Desktop. Fresh tasks still received bothPATHandPath, suggesting Desktop adds the second key after that policy is applied.This is not repository-specific and can affect any Windows tool that treats environment keys case-insensitively or modifies one PATH variant before spawning a child process.