Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
blueyed opened this issue Aug 20, 2021 · 3 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@blueyed
Copy link
Contributor

blueyed commented Aug 20, 2021

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

@finswimmer
Copy link
Member

Hello @blueyed,

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

fin swimmer

@finswimmer finswimmer added the status/waiting-on-response Waiting on response from author label Aug 27, 2021
@blueyed
Copy link
Contributor Author

blueyed commented Aug 27, 2021

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

@finswimmer finswimmer removed the status/waiting-on-response Waiting on response from author label Dec 17, 2021
@finswimmer finswimmer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants