Poetry continues to use existing virtualenv after virtualenvs.create
is set to false
#1890
Closed
3 tasks done
Labels
kind/bug
Something isn't working as expected
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: Debian 5.4.8-1 (sid)
Poetry version: 1.0.2 (installed via
pip
)Link of a Gist with the contents of your pyproject.toml file: N/A
Issue
I noticed that if I first use poetry with a virtualenv for a project, then set
virtualenvs.create
to false, poetry will continue to use the virtualenv, butpoetry env info
will imply otherwise.To reproduce:
1. create new project (with default config, aka venvs enabled)
So far so good
2. Set
virtualenvs.create
to falsePoetry seems to have "forgotten" the venv. However...
3. Try to use without the venv
Poetry is still considering everything to be up-to-date! (and does not mention "Skipping virtualenv creation, as specified in config file.")
And trying to run a shell still put me into the venv.
Observations
If I now create a new project, everything works as expected and poetry will not use a venv for it. But the old project continues to use the existing venv, despite
poetry env info
implying otherwise.I get that the doc for
virtualenvs.create
says "Create a new virtual environment if one doesn't already exist", so this behavior may be deemed to be correct. But:poetry env info
seems to give misleading information (or did I misunderstood?)If the behavior of
virtualenvs.create
is to be kept unchanged (I guess it could cause some backward compatibility issues otherwise), I would suggest providing another configuration option, e.g.virtualenvs.disable
, to give the possibility of disabling venvs altogether (for example to use in CI, or possibly inside docker images I guess... see context below).For context, I discovered the bug after being bitten by it while configuring poetry for CI. I first configured poetry to use a venv and (mistakenly) added it to the cache. Afterward I changed the CI by configuring poetry to not create a venv. But due to this behavior it kept using the cached venv on subsequent runs, causing some head-scratching.
Only after cleaning the CI cache did poetry start to behave as expected.
The text was updated successfully, but these errors were encountered: