At first I want to say many thanks to @kennethreitz for this great package. It makes working with virtual environment much easier and offers a straight workflow that fits perfectly in my toolchain.
So here is what I just experienced. I' m not sure if it is a bug or intentional. I just tried to uninstall a package which I before installed as a development package. So what I did was
$ pipenv uninstall -d somepackage
However the result was very unexpected for me. pipenv uninstalled all my dev packages. I then had a look at the help and it was completely clear and said that the -d or --dev flag uninstalls all development packages. So it was completely my fault but I could imagine this happening to quite a few folks.
I would suggest that the script should check for inappropriate parameters (like package names) and interrupt execution if they occur to prevent unintended uninstalls.
Hi @MrLeeh! Thanks for using pipenv! I think this is by design. If you just do pipenv uninstall dev-package
it will look through packages and dev packages to uninstall just that package. --dev
for install makes sense as we need to ensure the package gets put in the correct section, but for uninstall having it remove all also makes sense. I'll let @kennethreitz weigh in here on this feature request!
@erinxocon i got bit by this today as well. I'd say it doesn't make sense for --dev
to have such different meanings for install
and uninstall
, particularly since the meaning with uninstall
is so surprising and destructive.
My feature request would be to rename the option on uninstall
to more clearly communicate that it removes all dev packages. Though the docs are clear, I think the message here is that @MrLeeh and I both assumed it did the same thing for the two commands and therefore didn't look at the docs.
@brettdh would it be sufficient to just have a confirmation? I.e. _Are you sure you want to uninstall all dev packages?_
So I think I found a use case where we need to do some more checking for this. If you for some reason have a package in both dev and production, and issue an uninstall, it removed it from both the dev and packages sections. Specifiying --dev would only remove the package from the dev section, not both.
So after looking at the code, this wouldn't be possible without a lot of rework. If you have the same package installed for dev and regular packages, it's the same reference, so removing it from dev automatically removes it from the regular and vice versa. For now the --dev functionality will stay as it is. I did however rename it from --dev
to --all-dev
to be more consistent with the --all
removal functionality.
So to summerize
--all
removes everything and purges the environment
--all-dev
removes only all of the dev packages
pipenv uninstall packageName
removes any instance of that package from the Pipfile, dev, and regular deps.
@erinxocon I like your solution. It is much more explicit now. How about the short form?
pipenv uninstall -d
This one got me in trouble in the first place.
-d shouldn't work anymore...
@erinxocon if -d
doesn't exist we need to update the docs.
Disregard.
@nateprewitt I believe I removed that from the docs and added the new cli option.
@erinxocon I was conflating lock and uninstalls options.
@erinxocon Confirm. This pitfall is gone. Thanks for this.