pyenv-virtualenv
pyenv-virtualenv copied to clipboard
virtualenv-delete -f can exit with non-zero return code
$ pyenv virtualenv-delete --help
Usage: pyenv virtualenv-delete [-f|--force] <virtualenv>
-f Attempt to remove the specified virtualenv without prompting
for confirmation. If the virtualenv does not exist, do not
display an error message.
See `pyenv virtualenvs` for a complete list of installed versions.
yet
$ pyenv virtualenv-delete -f nonexistant
pyenv-virtualenv: `nonexistant' is not a virtualenv.
$ echo $?
1
Currently, 2 ENOENT-ish error codes can be printed without checking the value of $FORCE. More importantly, the script exits with a non-zero return code, which seems contrary to the spirit of -f.
https://github.com/pyenv/pyenv-virtualenv/blob/294f64f76b6b7fbf1a22a4ebba7710faa75c21f7/bin/pyenv-virtualenv-delete#L68-L89
I know this issue is extremely old. I had the same issue. You can step around it by executing pyenv uninstall -f nonexistent instead and it will remove the virtual environment.
Hello, same issue here with pyenv 2.3.1-20-g572a8bcf
I know this issue is extremely old. I had the same issue. You can step around it by executing
pyenv uninstall -f nonexistentinstead and it will remove the virtual environment.
@tamaroth I have found your work around doesn't work. Let's say I have a virtual env foo:
$ pyenv versions
system
* 3.9.12 (set by /home/foobar/.pyenv/version)
3.9.12/envs/foo
foo
Then I:
$ pyenv uninstall -f 3.9.12/envs/foo
pyenv: foo uninstalled
But now:
$ pyenv versions
system
* 3.9.12 (set by /home/foobar/.pyenv/version)
3.9.12/envs/foo
It didn't actually delete foo, just the extra name for the real venv. Still the same outcome if I use the short name, foo:
$ pyenv uninstall -f foo
pyenv: foo uninstalled
$ pyenv versions
system
* 3.9.12 (set by /home/foobar/.pyenv/version)
3.9.12/envs/foo
Ohh, I've found if you use the full venv name with virtualenv-delete it works:
$ pyenv virtualenv-delete --force 3.9.12/envs/foo
Doesn't matter if it doesn't exist either, it's always silent, always 0 return code.
Can't reproduce now.