[Feature] Command to move project folder, and command to scan for and remove orphaned virtualenvs #4934
Labels
Contributor Candidate
The issue has been identified/triaged and contributions are welcomed/encouraged.
Type: Enhancement 💡
This is a feature or enhancement request.
Pipenv currently places all virtualenvs in
~/.local/share/virtualenvs/
within folders named after the hashed project path. This is great, since it ensures that the per-platform libraries in your virtualenvs aren't incorrectly shared or included in VCS by beginners. Experts can of course change the venv location manually.However, the (good) default behavior leads to a lot of orphans if you delete, rename or move the project folders. And since pipenv is responsible for creating this situation, it is appropriate for it to take responsibility for all the orphans it's creating, since it's a heavy mind burden for users to try to manually clean the virtual environments.
I propose two commands to fix this situation.
pipenv move-project <oldpath> <newpath>
shutil.move()
the project path. If it fails, such as due to Windows "file open/in use" errors, simply rollback the change and stop here..project
, and the absolute path to the venv insidebin/activate
script, and maybe more). If any of these edits fail, rollback everything.pipenv remove-orphans
~/.local/share/virtualenvs/
..project
file (which contains the path to the project folder).Do you want to remove the venv for "/home/foobar/projects/old-project"? [N/y]
(it's important that it's no by default since the path may simply be on a disk that's not yet mounted).These two features would make pipenv a much "cleaner" tool. It wouldn't be such a hassle to move projects to new/renamed folders anymore, and any remaining orphans could be cleaned up manually.
The text was updated successfully, but these errors were encountered: