
Here is a Bourne-compatible shell function (without any known Bashisms) that takes a list of formulae, removes each one's dependencies, removes all copies of the formula itself, and then reinstalls any missing dependencies. The posted one-liners can also be tedious to work with if you want to uninstall more than one formula at a time. In particular, most of them will remove dependencies but still leave it up to you to remove the originally-targeted formula afterwards. There are a number of good answers already, but some are out of date and none of them are entirely complete.
Linux brew install#
Package gpg and its dependancies have been removed. This is exactly what I had to do and what it told me to do, but I refrained from pasting those commands as they showed up only on my machine on running the install command from their official website for HomeBrew installation, while it didnt have a second step in the installation process on my friends machine as new as mine (A day old). Uninstalling /usr/local/Cellar/libgpg-error/1.35. Uninstalling /usr/local/Cellar/libffi/3.2.1. Uninstalling /usr/local/Cellar/gmp/6.1.2_2. Uninstalling /usr/local/Cellar/nettle/3.4.1. Uninstalling /usr/local/Cellar/libunistring/0.9.10.

Uninstalling /usr/local/Cellar/libtasn1/4.13. Uninstalling /usr/local/Cellar/libassuan/2.5.3. Uninstalling /usr/local/Cellar/pinentry/1.1.0_1. Uninstalling /usr/local/Cellar/libusb/1.0.22. Uninstalling /usr/local/Cellar/libksba/1.3.5. Uninstalling /usr/local/Cellar/libgcrypt/1.8.4. Uninstalling /usr/local/Cellar/gnutls/3.6.6. Uninstalling /usr/local/Cellar/adns/1.5.1. Uninstalling /usr/local/Cellar/gnupg/2.2.13. Now install it with the following command sudo install brew-purge /usr/local/bin #:Removes the package and all dependancies.Įcho Package $PKG and its dependancies have been removed. Save the following script as brew-purge #!/bin/bash See the comment on the issue mentioned above for more info. Combine this with xargs and you'll get what you need, I guess (untested, don't count on this).ĮDIT: Somebody just suggested a very similar solution, using join instead of xargs: brew rm FORMULAīrew rm $(join <(brew leaves) <(brew deps FORMULA)) If you do a logical and on the output of brew leaves and brew deps, you might just get a list of the orphaned dependency packages, which you can uninstall manually afterwards.

There's an external command called brew leaves which prints all packages that are not dependencies of other packages.

However, I filed an issue on Homebrew's GitHub page, and somebody suggested a temporary solution until they add an exclusive command to solve this. It appears that currently, there's no easy way to accomplish this. See the above link for more information and discussion. To install and use, issue the following commands: $ brew tap beeftornado/rmtree It looks like the issue is now solved using an external command called brew rmdeps or brew rmtree.
