Skip to content

prepend_path_entry_for_apply_patch mangles $PATH and interferes with python virtualenv behavior #5225

Closed

Description

@Datamance

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.

Activity

  1. github-actions commented on Oct 15, 2025

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  2. etraut-openai commented on Jan 10, 2026

    @etraut-openai
    Contributor

    Closing old issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtool-callsIssues related to tool calling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions