WSL: codex-core safe-command test fails when Windows PowerShell is on PATH

Open
#34,897 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
powershell, rust

Research direction

Start with core/src/tools/handlers/shell_tests.rs and the named commands_generated_by_shell_command_handler_can_be_matched_by_is_known_safe_command test. Read try_find_powershell_executable_blocking(), try_find_pwsh_executable_blocking(), and the non-Windows is_known_safe_command path, then reproduce with the provided just test command under WSL2. Done means the upstream test suite passes in WSL without requiring non-Windows safety classification to accept discovered Windows PowerShell executables.

Written by the indexing model from the issue text.

Description

bug CLI windows-os
What version of Codex CLI is running?

codex-cli 0.145.0; also reproduced from openai/codex main at 44d76c6a6dd04fa2efc302b906ac8774267a1272.

What subscription do you have?

ChatGPT Pro.

Which model were you using?

Not applicable; this is a repository test failure.

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What terminal emulator and version are you using?

Windows Terminal with WSL2.

Codex doctor report

Not applicable; the failure reproduces in the Rust test suite on a clean upstream checkout.

What issue are you seeing?

just test -p codex-core commands_generated_by_shell_command_handler_can_be_matched_by_is_known_safe_command fails on WSL when Windows PowerShell executables are inherited through PATH:

thread 'tools::handlers::shell::tests::commands_generated_by_shell_command_handler_can_be_matched_by_is_known_safe_command' panicked at core/src/tools/handlers/shell_tests.rs:68:5:
assertion failed: is_known_safe_command(&shell.derive_exec_args(command, true))

The test conditionally exercises every PowerShell executable returned by try_find_powershell_executable_blocking() and try_find_pwsh_executable_blocking(). On WSL those functions find the Windows executables under /mnt/c, but the non-Windows implementation of is_known_safe_command intentionally does not accept PowerShell commands. The resulting expectations are contradictory on WSL.

What steps can reproduce the bug?
  1. Use WSL2 with Windows interop paths present in PATH.

  2. Confirm both commands resolve:

    command -v powershell.exe
    command -v pwsh.exe
    

    In this environment they resolve to:

    /mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe
    /mnt/c/Program Files/PowerShell/7/pwsh.exe
    
  3. Check out upstream commit 44d76c6a6dd04fa2efc302b906ac8774267a1272.

  4. Run:

    just test -p codex-core commands_generated_by_shell_command_handler_can_be_matched_by_is_known_safe_command
    

The test fails on both nextest attempts.

What is the expected behavior?

The upstream test suite should pass in a normal WSL environment. The test should not require non-Windows safety classification to accept Windows PowerShell executables merely because WSL can discover them.

Additional information

No fork-owned code is needed to reproduce this. The same exact test fails from detached upstream main at the commit above.

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.