`prepend_path_entry_for_apply_patch` mangles $PATH and interferes with python virtualenv behavior

Resolved 💬 2 comments Opened Oct 15, 2025 by Datamance Closed Jan 10, 2026

What version of Codex is running?

codex-cli 0.46.0

What subscription do you have?

Using the API

Which model were you using?

doesn't matter

What platform is your computer?

Darwin 25.0.0 arm64 arm

What issue are you seeing?

The title. This is bad behavior! Don't go willy nilly screwing with user paths (or any environment vars, for that matter) - they get exported and we expect programs to respect their configured behavior.

What steps can reproduce the bug?

Try to have codex call python from within a virtual environment.

Try !echo $PATH | tr ':' '\n' from inside the codex prompt and see what shows up, vs when you call it in your shell.

If you manually instruct codex to use the full path, it'll run the correct python and access all your dependencies just fine.

What is the expected behavior?

Codex should just be able to call python without having to specify the full path. Defeats the purpose of a virtualenv otherwise :)

Additional information

The fundamental issue is architectural: prepend_path_entry_for_apply_patch modifies the global process environment at the very start of arg0_dispatch_or_else, before the Tokio runtime is even created. This modified environment becomes the baseline for all subsequent operations, including:

  • Configuration loading
  • Subprocess spawning
  • Shell profile sourcing

So no, there are no configuration solutions to bypass this issue.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗