Skip to content

poetry recreates empty virtualenv with missing/broken $VIRTUAL_ENV and virtualenvs.in-project = null #4413

Closed as not planned

Description

@blueyed

I've moved away .venv, which was pointed at by $VIRTUAL_ENV, and had run poetry install in a new shell already, where $VIRTUAL_ENV was not set anymore.

Running poetry show in the old shell with the non-existing $VIRTUAL_ENV resulted in:

% poetry show
The virtual environment found in …/project/.venv seems to be broken.
Recreating virtualenv project-EfzD9vF2-py3.9 in …/.cache/pypoetry/virtualenvs/project-EfzD9vF2-py3.9
…

Re-creating (or rather emptying) the existing virtualenv is not necessary in this case, and causes confusion when using poetry run foo then later, where foo gets used from the system, since it is not installed again yet in the virtualenv.

I think the idea with $VIRTUAL_ENV being used and virtualenvs.in-project = null is that it would be used in this case, but when $VIRTUAL_ENV points at something non-existing it should be considered to be unset (i.e. get ignored).

(I could also imagine that it would actually re-create it, but then it should re-create what VIRTUAL_ENV points at, since that is what is going to be used the next time around again.)

% poetry config --list
cache-dir = "/home/user/.cache/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/user/.cache/pypoetry/virtualenvs

Using poetry 1.1.7.

Related: #3353

Activity

  1. added
    kind/bugSomething isn't working as expected
    status/triageThis issue needs to be triaged
    on Aug 20, 2021
  2. finswimmer commented on Aug 27, 2021

    @finswimmer
    Member

    Hello @blueyed,

    unfortunately I cannot follow you, how to reproduce your issue. Could you please add a step-by-step description?

    fin swimmer

  3. blueyed commented on Aug 27, 2021

    @blueyed
    ContributorAuthor

    Given a poetry managed project, e.g. with the following pyproject.toml:

    [tool.poetry]
    name = "test-poetry"
    version = "0.1.0"
    description = ""
    authors = []
    
    [tool.poetry.dependencies]
    python = "*"
    
    [tool.poetry.dev-dependencies]
    
    [build-system]
    requires = ["poetry-core>=1.0.0"]
    build-backend = "poetry.core.masonry.api"

    Create/init it:

    % poetry install
    Creating virtualenv test-poetry-EM-dhAoD-py3.9 in /home/user/.cache/pypoetry/virtualenvs
    Updating dependencies
    Resolving dependencies... (0.1s)
    
    Writing lock file
    

    When using an invalid $VIRTUAL_ENV it causes the existing virtualenv to be re-created/emptied:

    % VIRTUAL_ENV=/does/not/exist poetry install
    The virtual environment found in /does/not/exist seems to be broken.
    Recreating virtualenv test-poetry-EM-dhAoD-py3.9 in /home/user/.cache/pypoetry/virtualenvs/test-poetry-EM-dhAoD-py3.9
    Installing dependencies from lock file
    
  4. github-actions commented on Apr 12, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  5. locked as resolved and limited conversation to collaborators on Apr 12, 2024
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

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions