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 env remove with virtualenvs.in-project = true #2124

Closed
3 tasks done
fgervais opened this issue Mar 3, 2020 · 13 comments · Fixed by #9118
Closed
3 tasks done

poetry env remove with virtualenvs.in-project = true #2124

fgervais opened this issue Mar 3, 2020 · 13 comments · Fixed by #9118
Labels
area/cli Related to the command line area/venv Related to virtualenv management kind/bug Something isn't working as expected

Comments

@fgervais
Copy link

fgervais commented Mar 3, 2020

  • 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: 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.
@fgervais fgervais added the kind/bug Something isn't working as expected label Mar 3, 2020
@finswimmer finswimmer added area/cli Related to the command line area/venv Related to virtualenv management labels Mar 3, 2020
@esciara
Copy link

esciara commented Mar 10, 2020

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

@ketozhang
Copy link

ketozhang commented Apr 5, 2020

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 .

@jidicula
Copy link

jidicula commented Jun 7, 2021

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

@deepaerial
Copy link

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│ 

@sadransh
Copy link

sadransh commented Feb 18, 2022

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 !

@PeterBaker0
Copy link

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)

@geozeke
Copy link

geozeke commented Oct 18, 2022

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

@Eschivo
Copy link

Eschivo commented Dec 6, 2022

Same behavior also on Windows 10 (not mentioned by anyone before). I confirm that the workaround proposed by @geozeke works fine.

@princelySid
Copy link

I just came across the same problem. Using Poetry (version 1.2.2)

@esciara
Copy link

esciara commented Feb 14, 2023

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 ?

@princelySid
Copy link

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: 

@yozachar
Copy link

This issue still persists in 1.5.1. poetry env remove --all works for now.

abn added a commit to abn/poetry that referenced this issue Mar 5, 2024
abn added a commit to abn/poetry that referenced this issue Mar 5, 2024
abn added a commit to abn/poetry that referenced this issue Mar 6, 2024
abn added a commit to abn/poetry that referenced this issue Mar 8, 2024
abn added a commit to abn/poetry that referenced this issue Mar 9, 2024
abn added a commit to abn/poetry that referenced this issue Mar 9, 2024
@abn abn closed this as completed in #9118 Mar 10, 2024
abn added a commit that referenced this issue Mar 10, 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 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/cli Related to the command line area/venv Related to virtualenv management kind/bug Something isn't working as expected
Projects
None yet