poetry
poetry copied to clipboard
poetry env remove with virtualenvs.in-project = true
-
[x] I am on the latest Poetry version.
-
[x] I have searched the issues of this repo and believe that this is not a duplicate.
-
[x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: 18.04.3 LTS (Bionic Beaver)
-
Poetry version: Poetry version 1.0.5
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/fgervais/5a33d9df4cca064f02ce7fa6136c7e5e
Issue
I think poetry env remove
fails when virtualenvs.in-project = true
$ poetry env info
Virtualenv
Python: 3.6.9
Implementation: CPython
Path: /home/fgervais/personal/test/.venv
Valid: True
System
Platform: linux
OS: posix
Python: /usr
$ poetry config --list
cache-dir = "/home/fgervais/.cache/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/fgervais/.cache/pypoetry/virtualenvs
$ poetry env remove 3.6.9
[ValueError]
Environment "test-dT4kcP9T-py3.6" does not exist.
Found the same bug on macos:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.3
BuildVersion: 19D76
$ uname -a
Darwin Ems-MacBook-Pro 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
Same issue with a more relative command
$ poetry env remove .venv/bin/python
The current hotfix is to just remove .venv/
. However, I am not sure if there's consequences like state changes in $POETRY_HOME
In addition, requesting more simple relative remove command
$ poetry env remove .
Also encountered the same bug on macOS 11:
❯ sw_vers
ProductName: macOS
ProductVersion: 11.4
BuildVersion: 20F71
❯ uname -a
Darwin hostname 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
Is this issue is still active? I found the same problem on macOS 11.6 Big Sur with Python 3.9 and poetry version 1.1.12:
$ poetry env remove .venv
/bin/sh: .venv: command not found
EnvCommandError
Command .venv -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output:
at ~/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/utils/env.py:625 in remove
621│ shell=True,
622│ )
623│ )
624│ except CalledProcessError as e:
→ 625│ raise EnvCommandError(e)
626│
627│ python_version = Version.parse(python_version.strip())
628│ minor = "{}.{}".format(python_version.major, python_version.minor)
629│
Have the exact same problem on Ubuntu with two env with similar python version but different locations.
Just removed .venv
from project folder. Seems to be safe, as it disappeared from poetry env list
!
Same issue - can't find a way to use poetry env remove
with .venv
local virtual environment.
Getting errors like:
/bin/sh: 1: .venv: not found
EnvCommandError
Command .venv -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output:
at ~/.poetry/lib/poetry/utils/env.py:625 in remove
621│ shell=True,
622│ )
623│ )
624│ except CalledProcessError as e:
→ 625│ raise EnvCommandError(e)
626│
627│ python_version = Version.parse(python_version.strip())
628│ minor = "{}.{}".format(python_version.major, python_version.minor)
Same issue (Ubuntu 22.04). Interestingly, if the only virtual environment you have is a local .venv
in your project, this works fine:
poetry env remove --all
Same behavior also on Windows 10 (not mentioned by anyone before). I confirm that the workaround proposed by @geozeke works fine.
I just came across the same problem. Using Poetry (version 1.2.2)
I just came across the same problem. Using Poetry (version 1.2.2)
Latest version is 1.3.2. Did you try with that one ?
I just came across the same problem. Using Poetry (version 1.2.2)
Latest version is 1.3.2. Did you try with that one ?
Yes. The error I got:
/bin/sh: .venv: command not found
Command .venv -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output:
This issue still persists in 1.5.1
. poetry env remove --all
works for now.
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.