Add an option to brew rm
to uninstall / remove a package, including all it's dependencies.
#7465
Comments
To really do this properly, the metadata in the formulae isn't enough. Things that don't specify an explicit dependency on something might link against it anyway if it happens to be present already, and removing it will break things in that case. |
@jacknagel: I don't understand, aren't all of a given package's dependencies listed on its formula? What should be done seems simple in concept:
|
In theory yes. But sometimes packages that aren't dependencies get picked up by other packages configure scripts, even if they are not required. And removing them will break things. |
@jacknagel: Well, I guess that's the formula's responsibility to state its dependencies correctly, right? If these unstated packages are picked up by the configure scripts, what happens when they're absent when these scripts run? Do the formula break? |
No. What I'm saying is they are not "dependencies" in the sense that they are not required, and the formulae will build fine in their absence. But if they are present, they might get picked up anyway. |
@jacknagel: I understand now, thanks. I guess in these case, these unstated packages shouldn't be uninstalled, since they were installed prior to installing the given package. |
A better (safer) way to do this would be to run |
Well, at least we agree this option is necessary and helpful. :) |
Another example of the need to do this the safe way is if someone has run Not that we have to protect against everyone's silly mistakes. But there are a lot of corner cases. |
One thing I forgot to mention--you might be interested in
The more I think about it, the less I agree. In addition to the issues I mentioned before, there is this: how do you distinguish between "orphaned" formulae (those that were installed as dependencies of something else, but that something else has been removed) and formulae that have been installed explicitly? These are not always mutually exclusive. To illustrate, say I I don't think we can get any more clever than just looking at the output of [1] That reminds me that we should make an external commands man page. |
Jack is right, but we should be aware of this stuff and deal with it as it happens. It is not a reason to not implement this feature. However I can't be arsed. As you said "It shouldn't be that hard" so hopefully someone is motivated. |
Created issue #7475 for creating an external commands man page. This (7465) issue is for creating a command for removing a package along its dependencies, if they're going to become orphaned after the given package's removal. |
In the interim, one could probably do this:
to uninstall all deps of FORMULA that have been orphaned. |
Not sure if I'm bringing up an old, and dead, discussion, but...this would be pretty neat and handy.
or
would be very appriciative. |
Patch welcome. Maybe one day I'll get around to it. But one day has become three years already. |
This can be added now as an external command; call it |
Closing, but will consider an external command that does this. |
Did this command ever get created? |
No. |
It'd be useful. |
Very useful, like Arch's -s, --recursiveRemove each target specified including all of their dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and analogous to a backwards --sync operation, and helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice. |
If someone implements it we'll review a PR. Being increasingly specific about what it should do is less productive than actually trying to implement it 😄 |
For everyone who comes here looking for an implementation of |
Been tapped...
|
@beeftornado I just tried out your script, and it seems to be working pretty well so far! I agree that it would be useful to have something like this in brew. We could always warn the user about some of the edge cases mentioned previously (maybe we could force a confirmation the first time the command is used or something like that?). |
I've searched over the www for a way to make Homebrew uninstall a package without leaving junk behind it, and haven't found anything useful.
Let's say I want to uninstall
python
package, which depends onreadline
package.readline
is currently only used bypython
on my system, and not by any other package.When I
brew uninstall python
I also want to uninstallreadline
, without having to search for the dependencies myself and check if it's okay to remove them manually. With many packages installed this process becomes cumbersome and time-consuming.There should be an option to
brew rm
to do that. It shouldn't be that difficult. Just involves a clever use ofbrew deps
&brew uses
, I suppose.The text was updated successfully, but these errors were encountered: