python-poetry / python-poetry/poetry

`poetry env delete` and `poetry env list` should be able to deal with broken envs after a Python upgrade

Open
#9,389 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Issue Kind

Change in current behaviour

Description

I ran into https://github.com/python-poetry/poetry/issues/6841, and it is difficult to recover from. I believe the cause of the problem was that the python symlink inside the virtual env pointed to a binary that no longer existed on my system

I wish that:

  1. poetry env delete --all worked in that situation. It currently fails with [Errno 2] No such file or directory: 'python'. Ideally, poetry debug info would also work. It currently prints some information, but fails in the same way before printing the useful information of where the virtualenvs are.
  2. the error messages suggested I use poetry env delete.
Impact

See above

Workarounds

One can check that poetry config virtualenvs.path is set to a sensible value (DO NOT SKIP THIS PART) and then run rm -r $(poetry config virtualenvs.path)/*.

This is taken from https://github.com/python-poetry/poetry/issues/6841#issuecomment-1284590137, which suggested running the above with rm -rf, but judging by the rest of the thread, many people did not check that poetry config virtualenvs.path is set to a reasonable value and nuked large parts of their system. 😬

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the poetry env delete --all, poetry env list, and poetry debug info entry points and reproduce a virtual environment whose python symlink targets a missing binary. Trace how each command discovers, reports, and removes environments, including the related error paths. Done means these commands handle the broken environment safely and error messages point users toward poetry env delete.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.