Duplicate PATH/Path variables in default permissions mode break Enter-VsDevShell on Windows

Open 💬 1 comment Opened May 16, 2026 by jsnchng

What version of Codex CLI is running?

codex-cli 0.130.0

What subscription do you have?

ChatGPT Plus

Which model were you using?

gpt-5.5

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

PowerShell

Codex doctor report

What issue are you seeing?

Prompts:

Run the following 2 commands in powershell:
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Community" -DevCmdArguments "-arch=x64"

Error message:

Enter-VsDevShell : An item with the same key has already been added. Key: PATH
At line:3 char:1
+ Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Vis ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Enter-VsDevShell], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.VisualStudio.DevShell.Commands.EnterVsDevShellCommand

What steps can reproduce the bug?

  1. Launch Codex CLI on Windows using the default permissions / auto-review mode.
  1. Prompt Codex to execute the following PowerShell command:
[Environment]::GetEnvironmentVariables("Process").Keys |
  Where-Object { $_ -ieq "Path" }
  1. Observe that Codex's PowerShell session contains both:

```text id="jlwmol"
Path
PATH


4. Prompt Codex to execute the following commands:

```powershell
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"

Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Community" -DevCmdArguments "-arch=x64"
  1. Observe the failure:
Enter-VsDevShell : An item with the same key has already been added. Key: PATH
  1. Prompt Codex to remove the duplicate uppercase PATH variable before re-run Enter-VsDevShell:
Remove-Item Env:PATH

Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"

Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Community" -DevCmdArguments "-arch=x64"
  1. Observe that the MSVC developer environment initializes successfully.
**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.14.32
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗