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

CLI command to remove all old environments #1884

Closed
2 tasks done
zachvalenta opened this issue Jan 14, 2020 · 8 comments · Fixed by #3212
Closed
2 tasks done

CLI command to remove all old environments #1884

zachvalenta opened this issue Jan 14, 2020 · 8 comments · Fixed by #3212
Labels
kind/feature Feature requests/implementations

Comments

@zachvalenta
Copy link

Feature Request

tldr: Is there a way to way to clean up old environments en masse?

context: I often spin up a quick project to explore an idea and then tear it down once I'm past the exploration phase. Using pip, the environment could be co-located to the project i.e. rm <my_project> would also remove the environment. With Poetry, environments are located outside the project, and thus it's possible to delete the project without deleting the environment. As a result, you could have environments at path/to/pypoetry/virtualenvs/ whose projects have been deleted. Currently, Poetry only offers the ability to remove an environment using the CLI from within the project itself; if you've already deleted the project, you need to navigate to path/to/pypoetry/virtualenvs/ and manually remove its hanging environment. It'd be nice if Poetry had a CLI command in which you could remove all environments that no longer correspond to source code directories on the operating system.

@zachvalenta zachvalenta added the kind/feature Feature requests/implementations label Jan 14, 2020
@finswimmer
Copy link
Member

Hello,

you can config poetry to put the venv within the project using virtualenvs.in-project true.

I don't think it is possible to remove venv where the project does not exists anymore via CLI, because there is no information about where the location of the project was.

Having a command to cleanup all venv for an existing project should be possible and seems quite useful to me.

fin swimmer

@jtrakk
Copy link
Contributor

jtrakk commented Jan 18, 2020

There could be an option

poetry env remove --all

or it could be

poetry env remove one python3.6
poetry env remove all

@abn
Copy link
Member

abn commented May 9, 2022

Resolved-by: #3212

@abn abn closed this as completed May 9, 2022
@am1006
Copy link

am1006 commented Sep 26, 2022

Resolved-by: #3212

Not sure if this was answered before. After trial and error, I don't quite get how this merge could fix the problem that OP tried to fix. From #3212 I can see that the -all argument can remove all environments that are attached to the current project. Could you advise me how this will remove all hanging environments (i.e., the problem that OP raised)?

@neersighted
Copy link
Member

I think there is a misunderstanding of "all old environments for the current project" vs "all old environments" period. Unfortunately the latter is not possible as we use a one-way hash function and there is no way to determine if an environment is still associated with a valid Python project.

@DominikRoB
Copy link

Found this here, because I have the same issue as OP.
Is it fine to delete environments (hanging or not) from path/to/pypoetry/virtualenvs/ or are there negative consequences?

@vpunch
Copy link

vpunch commented Nov 9, 2023

Resolved-by: #3212

It is not a solution to the problem described by the author. I also find it strange that poetry does not delete virtual environments after deleting the directory with the project.

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants