codex - 💡(How to fix) Fix Duplicate PATH/Path variables in default permissions mode break Enter-VsDevShell on Windows

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…

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

Code Example



---

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"

---

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

---

[Environment]::GetEnvironmentVariables("Process").Keys |
  Where-Object { $_ -ieq "Path" }

---

4. Prompt Codex to execute the following commands:

---

5. Observe the failure:

---

6. Prompt Codex to remove the duplicate uppercase `PATH` variable before re-run `Enter-VsDevShell`:

---

7. Observe that the MSVC developer environment initializes successfully.
RAW_BUFFERClick to expand / collapse

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.

  2. 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:
Path
PATH
  1. Prompt Codex to execute the following commands:
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

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