Hello @azdkj532,
this is definitly not the default behaviour. I guess you have set in in your config, either global or local, sometime before :)
fin swimmer
I am surprised by the answer of fin swimmer
this is my config.
poetry config --list
cache-dir = "/Users/etijskens/Library/Caches/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/etijskens/Library/Caches/pypoetry/virtualenvs
I see no reference that '.venv' is the default name...
@finswimmer Could you have a look on this ? May it's a bug.
~/Workspace/plurkcore(master ✗) poetry env info
Virtualenv
Python: 2.7.17
Implementation: CPython
Path: /home/larry/.cache/pypoetry/virtualenvs/plurkcore-xdkz89K8-py2.7
Valid: True
System
Platform: linux
OS: posix
Python: /home/larry/.pyenv/versions/2.7.17
~/Workspace/plurkcore(master ✗) virtualenv .venv
New python executable in /home/larry/Workspace/plurkcore/.venv/bin/python2.7
Also creating executable in /home/larry/Workspace/plurkcore/.venv/bin/python
Installing setuptools, pip, wheel...
done.
~/Workspace/plurkcore(master ✗) poetry env info
Virtualenv
Python: 2.7.17
Implementation: CPython
Path: /home/larry/Workspace/plurkcore/.venv
Valid: True
System
Platform: linux
OS: posix
Python: /home/larry/.pyenv/versions/2.7.17
~/Workspace/plurkcore(master ✗) poetry config --list
cache-dir = "/home/larry/.cache/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/larry/.cache/pypoetry/virtualenvs
It seems that it doesn't respect the configuration.
@etijskens: You have virtualenvs.in-project = true in your config. poetry then creates the venv within the project and calls the folder .venv. The name is hardcoded.
@azdkj532: Ah, I see now. I guess this is a bug. If virtualenvs.in-project = false is set, poetry shouldn't look for .venv within the project folder.
Reopen this issue.
Thanks for reporting!
fin swimmer
@finswimmer: thanks for the clarification. So the virtual environment name can only be defined by the user for non-local environments... which I guess is not documented.
When virtualenvs.in-project = true poetry will create venv inside .venv folder, but if there is already a .venv there poetry can also show it in poetry env info, even if virtualenvs.in-project = false. I think it is what user expect when the use poetry to manage old project with a local .venv folder. We can make the directory name configurable though.
The more I think about the issue, the less I'm sure that it is a bug. Maybe it's the intended behavior and needs to get documentated as you said @azdkj532. Let's see what @sdispater said.
@frostming Now .venv directly replaces existed virtual environment instead of just appending to environment list. Before useing command poetry env use ... to select their environment, it's OK to use .venv by default. But current behavior causes distress to user while .venv is activated automatically and didn't appear in poetry env list .
IMO, this feature could be changed into
.venv into poetry env list automatically.poetry env use ...Additional information: Poetry use .venv even it's invalid.
larry@squirrelmac /tmp/project$ poetry env info 130 ↵
Virtualenv
Python: 3.7.1
Implementation: CPython
Path: NA
System
Platform: darwin
OS: posix
Python: /Users/larry/.pyenv/versions/3.7.1/Python.framework/Versions/3.7
larry@squirrelmac /tmp/project$ mkdir .venv
larry@squirrelmac /tmp/project$ poetry env info
Virtualenv
Python: 3.7.1
Implementation: CPython
Path: /private/tmp/project/.venv
Valid: False
System
Platform: darwin
OS: posix
Python: /Users/larry/.pyenv/versions/3.7.1/Python.framework/Versions/3.7
larry@squirrelmac /tmp/project$ poetry env use 3.7
Creating virtualenv test-FIFGH_JX-py3.7 in /Users/larry/Library/Caches/pypoetry/virtualenvs
Using virtualenv: /private/tmp/project/.venv
larry@squirrelmac /tmp/project$ poetry env info
Virtualenv
Python: 3.7.1
Implementation: CPython
Path: /private/tmp/project/.venv
Valid: False
System
Platform: darwin
OS: posix
Python: /Users/larry/.pyenv/versions/3.7.1/Python.framework/Versions/3.7
Hi,
copying over, what I wrote in #967:
I had the expectations, that if
virtualenvs.in-project falseandvirtualenvs.pathset to a path, poetry would ignore the in project .venv folder. Treating local .venv differently is imho surprising in this scenario.
The use case we have:
virtualenvs.in-project=truevirtualenvs.in-project=false and virtualenvs.path=/venv Right now, we work around this issue by exporting the VIRTUAL_ENV=/venv/path/to/bin/python and rm /venv/envs.toml.
Same issue here. I've got a Windows development machine, but code running in Docker with a mount. The local .venv includes Windows binaries etc., and even with virtualenvs.in-project false and virtualenvs.path configured, poetry keeps complaining about The virtual environment found in /project/mount/.venv seems to be broken. and then tries to recreate the env.
Really counter-intuitive behavior.
I agree that this is not an intuitive behavior.
I think we should make a distinction between the virtualenvs.in-project setting is not set (and keep the current behavior of using the local .venv virtual environment in this case) and if it's set explicitly to False.
That way, we make sure that it's possible to tell Poetry to not use the .venv virtual environment.
Most helpful comment
I agree that this is not an intuitive behavior.
I think we should make a distinction between the
virtualenvs.in-projectsetting is not set (and keep the current behavior of using the local.venvvirtual environment in this case) and if it's set explicitly toFalse.That way, we make sure that it's possible to tell Poetry to not use the
.venvvirtual environment.