Skip to content

$VIRTUAL_ENV and $PATH don't agree #494

@pillmuncher

Description

@pillmuncher

pyenv sets $VIRTUAL_ENV to:

$PYENV_ROOT/versions/<version>/envs/<venv>

but the shims point to the symlinks:

$PYENV_ROOT/versions/<venv>/bin/*

That annoys Neovim and my OCD. See:

Python virtualenv ~
- WARNING $VIRTUAL_ENV is set to: /home/mick/.local/state/pyenv/versions/3.12.7/envs/mutaid-msgenc
  And its bin directory contains: python, python3, python3.12
  But $PATH yields this python executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python
  And $PATH in subshells yields this python executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python
  And $PATH yields this python3 executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python3
  And $PATH in subshells yields this python3 executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python3
  And $PATH yields this python3.12 executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python3.12
  And $PATH in subshells yields this python3.12 executable: /home/mick/.local/state/pyenv/versions/mutaid-msgenc/bin/python3.12
  So invoking Python may lead to unexpected results.
  - ADVICE:
    - $PATH ambiguities in subshells typically are caused by your shell config overriding the $PATH previously set by the virtualenv. Either prevent them from doing so, or use this workaround: https://vi.stackexchange.com/a/34996
    - $PATH ambiguities arise if the virtualenv is not properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, check that invoking Python from the command line launches the correct one, then relaunch Nvim.

Shouldn't $PATH and $VIRTUAL_ENV (both set by pyenv!) agree on this and not be set to different paths into the same virtualenv?

Description

  • Platform information (e.g. Ubuntu Linux 16.04):
    Solus Linux Budgie 4.6 convergence

  • OS architecture (e.g. amd64):
    x86_64

  • pyenv version:
    2.4.17

  • Python version:
    3.12

  • C Compiler information (e.g. gcc 7.3):
    gcc (Solus) 14.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions