-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Summary
if .venv is an empty file and I run pipenv --rm, the entire ~/.local/share/virtualenvs directory is deleted. This happens even when there's no Pipfile present.
This is on macOS, pipenv version 2021.5.29.
Issue description
I was messing around with my project environment, and tried to tell my editor where to find the environment by putting it in .venv. Turns out that running pipenv --venv > .venv fails because it first touches .venv, and then the actual command looks at the empty .venv and doesn't find an environment. This causes the file to remain empty. (The command did print an error message in STDERR, but somehow I didn't notice it immediately.)
So now with an empty .venv in my project folder, I ran pipenv install <some package> and wondered why it said it had to create a new virtualenv. I looked at the output more closely and realized that the new env was created in /Users/myname/.local/share/virtualenvs (not in a subdirectory).
I got curious about what would happen if I now tried to scrap the thing, and as I feared, running pipenv --rm deleted that entire directory, which contained all the other virtualenvs that I had made with Pipenv for other projects earlier. It wasn't a big loss or I wouldn't have tried, but still not something I like to see happening.
Steps to replicate
In an empty directory:
touch .venv
pipenv --rm
Now the entire ~/.local/share/virtualenvs directory is deleted.
The way I ended up in this situation was actually essentially the following:
pipenv --python 3.9
pipenv --venv > .venv
pipenv install requests
pipenv --rm