Skip to content

poetry env remove removes wrong environment #6018

@KDMichaelis

Description

@KDMichaelis
  • 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: Ubuntu 20.04
  • Poetry version: 1.1.14

Issue

I created two poetry environments, project-tmp-1BotOSEK-py3.9 and tmp-project-yuY8E-Dp-py3.9. In my project only the first one is available and activated:

$ poetry env list
project-tmp-1BotOSEK-py3.9 (Activated)

I am trying to delete the other environment using the absolute path according to the documentation as follows:

$ poetry env remove /home/user/.cache/pypoetry/virtualenvs/tmp-project-yuY8E-Dp-py3.9/bin/python

However, this deletes the wrong environment (the activated one) instead:

Deleted virtualenv: /home/user/.cache/pypoetry/virtualenvs/project-tmp-1BotOSEK-py3.9

I would expect that using the absolute path exactly the specified environment would be deleted instead of the activated one, including any data connected to it (e.g. the entry in envs.toml). It actually seems that the entry for the correct (specified) environment was deleted but the wrong (activated) environment is erased instead, leading to inconsistent information in envs.toml.
If for some reason it is desired that a virtualenv cannot be deleted from a project where it's not available (or while another one is activated) the command should at least fail when trying to do so.
As a side note, I am using direnv and the command layout_poetry defined in ~/.direnvrc and called in .envrc within my project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/venvRelated to virtualenv managementkind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions