Skip to content

The target debug information reports PYTHONPATH entries in sys.path #3473

Closed

Description

@RaphaelFakhri

Issue

get_env_debug_info in src/virtualenv/create/creator.py copies the environment and removes PYTHONPATH from the copy, but then calls run_cmd(cmd) without that copy. run_cmd starts the process with the inherited environment, so the debug interpreter still sees PYTHONPATH. The environment passed to cli_run(env=...) is also not used for this process.

As a result, the target debug section of virtualenv -vv and Creator.debug list the caller's PYTHONPATH entries in the new environment's sys.path, which a plain run of the environment's interpreter without PYTHONPATH does not have.

Reproduce

$ mkdir /tmp/extra
$ PYTHONPATH=/tmp/extra virtualenv -vv --no-seed --activators "" /tmp/env 2>&1 | grep /tmp/extra
      "/tmp/extra",

Expected: no output, because the debug collection drops PYTHONPATH.

Environment

  • OS: Linux x86_64
  • Python 3.12.3
  • virtualenv 21.15.0 (main at 18d26f8)
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions