Skip to main content

How to Keep HomeBrew Clean on a Mac

HomeBrew is a package manager (similar to the linux "apt-get"/"zypper"/"yum" front end package managers that are usually shipped with different distros) with one exception: it was built for Apple MacOS systems as a solution since Apple doesn't offer or ship one with MacOS.

Dependencies


While HomeBrew is a great solution and offers most features other modern package managers offer and has a rich reposatory, it lacks some useful features that make it difficult to use for the purpose of managing installed packages. One issue that I would like to describe here is the lack automatic removal of dependencies.

HomeBrew does not keep logs of installed dependencies the same way that the popular Linux package managers do. Some packages require dependencies to work and while HomeBrew can detect the required dependencies and install them automatically as part of the installation process, it will not remove them automatically while removing packages.

This can lead to outdated unnecessary software with vulnerabilities being installed on the system.

The good news is that there is a solution for this issue: rmtree.
rmtree is (as its official GitHub page describes) an external HomeBrew command that allows the user to "Remove a formula and its unused dependencies."
While the page warns that it may not work in all cases, I personally found it usable and reliable.

The command can be added to HomeBrew by simply executing the following command:

$ brew tap beeftornado/rmtree

Once added, packages (and their dependencies) can be removed by using "brew rmtree" instead of the normal "brew remove".

Removing All Packages


Prefer to start over and remove all installed packages? Look not further!
Below is a command I put together that will accomplish this quickly and easily:


$ brew uninstall --ignore-dependencies --force $(brew list)


This command will obtain a list of all installed packages (With the help of the "brew list" command) and force all of them to be removed "ignoring" dependencies to eliminate any warnings from showing up.

Once this is done, I usually like to execute the "brew cleanup" and then the "brew doctor" commands to make sure that HomeBrew is fully clean and functional (the doctor command will make sure that there are no issues with HomeBrew).

It is also a good idea to execute "brew update" once in a while to make sure that the most recent version of HomeBrew is installed on the system.



Please note that the commands above will not remove or modify any casks.



Comments

Popular posts from this blog

Cloning your Mac / Linux hard drive/SSD with dd

In the process of upgrading my Mac SSD drive (which is a whole story of its own), I've come across many different methods of doing so. At one time, I was keeping "Time Machine" backups regularly which made the whole process quick and easy; I swapped the SSD cards and restored the most recent Time Machine backup from the hard drive I was keeping the backups on. Eventually, I came across another method that I was already familiar with already but didn't think of in this particular scenario. It evolves a command line utility called "dd" ( Wikipedia ) mainly used to copy and convert files. This cloning method works on Macs, Linux, FreeBSD and any unix-based systems. You will have to be familiar with the command line interface (Terminal). Normally the command looks like this: $ sudo dd if=/dev/sda of=/dev/sdb "sudo" is necessary as we are cloning a system drive. "if" is the input file - it is the original drive we wish to clone.

BBC Radio URL Streams

In 2014, the BBC made a decision not to support direct Windows Media Player URL streams ( The announcement ). Directing users to their iPlayer website/app. For those who are still interested in the old URL; paths to those streams (which still work yet not listed on the website), I made a list of all the addresses that I could find: BBC Radio 1 - http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-mp3-a/vpid/bbc_radio_one/format/pls.pls BBC Radio 1Xtra - http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-mp3-a/vpid/bbc_1xtra/format/pls.pls BBC Radio 2 - http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-mp3-a/vpid/bbc_radio_two/format/pls.pls BBC Radio 3 - http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-mp3-a/vpid/bbc_radio_three/format/pls.pls BBC Radio 4 - http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-mp3-a/vpid/bbc_radio_fourfm/format/pls.pls BBC Radio 4 Extra - http://ope