Skip to content

Fix VIRTUAL_ENV to be in agreement with executable paths - #529

Merged
native-api merged 1 commit into
pyenv:masterfrom
r3wretrhy:fix/virtual-env-symlink-path-494
Oct 12, 2026
Merged

native-api merged 1 commit into
pyenv:masterfrom
r3wretrhy:fix/virtual-env-symlink-path-494

Conversation

@r3wretrhy

@r3wretrhy r3wretrhy commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

pyenv activate resolves $PYENV_ROOT/versions/<name> through the symlink into .../versions/<base>/envs/<name> before exporting VIRTUAL_ENV. Shims keep the symlink path on PATH, so tools that compare the two (Neovim, for example) warn that they disagree.

Stop resolving that symlink on activate so VIRTUAL_ENV matches the path on PATH.

Fixes #494.


Summary by cubic

Fixes pyenv activate so VIRTUAL_ENV matches the symlink path that shims put on PATH, eliminating tool warnings (e.g. Neovim) about the two disagreeing.

  • Stops resolving the $PYENV_ROOT/versions/<name> symlink before exporting VIRTUAL_ENV; the prefix is now left as pyenv-prefix returned it.
  • Adds a regression test for $VIRTUAL_ENV and $PATH don't agree #494.

Written for commit 390b7ca. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@native-api native-api left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the problem statement, we should rather be testing that VIRTUAL_ENV is in agreement with PATH. Symlink resolution and stuff are but implementation details that are subject to change.

@r3wretrhy

Copy link
Copy Markdown
Contributor Author

Thanks @native-api — updated the regression test to assert the #494 property directly: after activate, VIRTUAL_ENV/bin/python matches the python that PATH yields (with the shim-facing versions/<name>/bin on PATH). Dropped the symlink-resolution assertion as an implementation detail.

@r3wretrhy
r3wretrhy force-pushed the fix/virtual-env-symlink-path-494 branch from 5c0e99c to 8893cb8 Compare October 4, 2026 07:01
Comment thread test/activate.bats Resolved
pyenv-virtualenv installs $PYENV_ROOT/versions/<name> as a symlink to
.../versions/<base>/envs/<name>, and shims put that symlink path on PATH.
Resolving the symlink when activating made VIRTUAL_ENV disagree with PATH,
which tools like Neovim warn about.

Leave the prefix as pyenv-prefix returned it so VIRTUAL_ENV matches PATH.
Adds a regression test for #494.
@r3wretrhy
r3wretrhy force-pushed the fix/virtual-env-symlink-path-494 branch from 8893cb8 to 390b7ca Compare October 5, 2026 14:32
@native-api native-api changed the title fix: keep VIRTUAL_ENV on the versions symlink path Fix VIRTUAL_ENV value to be in agreement with executable paths Oct 12, 2026
@native-api native-api changed the title Fix VIRTUAL_ENV value to be in agreement with executable paths Fix VIRTUAL_ENV to be in agreement with executable paths Oct 12, 2026
@native-api
native-api merged commit 1c9994a into pyenv:master Oct 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$VIRTUAL_ENV and $PATH don't agree

2 participants