choco
choco copied to clipboard
Very small but important: `Choco uninstall`: Please do not report an error if a package is not installed!
What You Are Seeing?
If the user starts choco uninstall to uninstall Software which is not installed, then the user gets an error:
choco uninstall winrar
Chocolatey v0.10.15
Uninstalling the following packages:
winrar
winrar is not installed. Cannot uninstall a non-existent package.
What is Expected?
If choco uninstall notices that the software is not installed, then this is not an error but the user's desired goal has been successfully achieved.
When it is reported as an error, some users are concerned: "Dear IT, what went wrong here? Have I done something wrong?"
Therefore, choco uninstall should do not report an error in this case, please,
but report that the command was successful because the desired goal was reached.
For example, Choco could report something like this:
choco uninstall winrar
Chocolatey v0.10.15
Uninstalling the following packages:
winrar
OK (winrar was not installed)
How Did You Get This To Happen? (Steps to Reproduce)
choco uninstall winrar
Chocolatey v0.10.15
Uninstalling the following packages:
winrar
winrar is not installed. Cannot uninstall a non-existent package.
Thanks a lot! kind regards, Thomas
One should not call uninstall if it's not installed: Don't change behavior, this is user error.
It sounds like you're looking for some sort of idempotence here @schittli. This isn't what you'd use a configuration manager for. What I would suggest is that if users are managing packages from the command line they understand how to do so. So if they are trying to uninstall package that doesn't exist I would expect them to know what they are doing and understand the clear error message that Chocolatey displays winrar is not installed. Cannot uninstall a non-existent package.. That to me is fairly clear and shouldn't result in any calls to IT.
However, I can see both sides of this argument. What does concern me is that this is a breaking change. I wonder whether an enhanced exit code might work for this. However, in the scenario above, I don't think this would help.
This appears to be a duplicate of #1451
Idempotence is important for automation purposes. If there are concerns about breaking behavior, please consider adding a flag to enable this behavior, e.g.
choco uninstall --silent
Idempotence is important for automation purposes. If there are concerns about breaking behavior, please consider adding a flag to enable this behavior, e.g.
choco uninstall --silent
Why can't you just automate detection first, then run uninstall only if detected?
--silent is not used to silence errors, traditionally.
This is what the win_chocolatey Ansible module does; list local packages to determine if things are installed, and simply do nothing if you request uninstallation of a non-existent package. Others could do similar, for sure.
There's something to be said perhaps for an opt-in on commands more generally like --idempotent perhaps, but I don't think it's a hugely important thing; there are plentiful workarounds here at the moment that work just fine.
Why can't you just automate detection first, then run uninstall only if detected?
Detect then delete is not an atomic operation and could run into race conditions and isn't ideal. Granted it's less of an issue for low-concurrency systems like package management.
Also - people often have automation needs without being fluent in the stack involved (i.e. few people are shell experts). Detect then delete raises the effort for them considerably.
--silent is not used to silence errors, traditionally.
Just an example - I think rm uses --force. And strictly speaking, it's not an error as there is no state change; an FYI maybe.
If choco uninstall notices that the software is not installed, then this is not an error but the user's desired goal has been successfully achieved.
How can Chocolatey know that? What if the user made a typo in the package ID, so for example tried to uninstall notpadplusplus instead of notepadplusplus. If Chocolatey continued on silently when a package was not found, then the user's desired goal would not have been successfully achieved, because the package they meant to uninstall (notepadplusplus) was still installed.
Not to say that an option like --skip-if-not-installed or --ignore-unfound is a bad idea, due to the aforementioned automation idempotence reason.
I'm going to close this as, on balance, it isn't something we'd be looking to implement.