windows: All shell commands crash with "Could not load netstandard 2.0.0.0" at PowerShell startup stage

Open 💬 1 comment Opened Mar 3, 2026 by CNTianQi233

Title

Windows: All shell commands crash with "Could not load netstandard 2.0.0.0" at PowerShell startup stage

Environment

  • codex-cli version: 0.107.0
  • OS: Microsoft Windows 10.0.26100
  • PowerShell versions: pwsh 7.5.4 (Microsoft Store) + Windows PowerShell 5.1
  • Node.js: v24.11.1

Bug Description

Every shell command executed inside Codex CLI fails immediately with a .NET assembly loading error, before the command itself runs. This happens regardless of sandbox mode or command content.

The crash occurs at PowerShell's own startup stage (ConsoleHost.Start / UnmanagedPSEntry.Start), not during command execution.

Steps to Reproduce

  1. Open PowerShell (pwsh 7.5.4), start Codex CLI with codex
  2. Enter any prompt that triggers a shell command, e.g. run: cmd /c echo hello
  3. Observe crash

Error Output

Process terminated. Could not load file or assembly 'netstandard, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 系统找不到指定的文件。

   at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, Boolean issProvidedExternally)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)

What I've Tried

| Test | Result |
|------|--------|
| powershell.exe -NoProfile -Command "echo hello" (manual) | ✅ Works |
| pwsh.exe -NoProfile -Command "echo hello" (manual) | ✅ Works |
| Any command inside Codex (e.g. cmd /c echo hello) | ❌ Crashes |
| --dangerously-bypass-approvals-and-sandbox (--yolo) | ❌ Still crashes |
| sandbox_mode = "danger-full-access" in config.toml | ❌ Still crashes |
| cmd /c set > env.txt inside Codex (to dump env) | ❌ Crashes, file not created |

Analysis

  • Both PowerShell 5.1 and pwsh 7.5.4 work perfectly when launched manually from the same terminal session.
  • The crash happens at UnmanagedPSEntry.Start, which is before any user command is evaluated.
  • Disabling the sandbox has no effect.
  • $env:DOTNET_ROOT is not set in the normal environment.
  • $env:PATH contains C:\Program Files\dotnet\ and standard system paths.

This strongly suggests that Codex's Rust process modifies the child process environment (e.g. PATH, DOTNET_ROOT, DOTNET_MULTILEVEL_LOOKUP, or COMPlus_* variables) in a way that breaks .NET's assembly resolution when spawning PowerShell.

Since all commands fail (including cmd /c), it appears Codex routes everything through a PowerShell host internally, making the CLI completely unusable on this machine.

View original on GitHub ↗

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