MacOS Homebrew – Uninstalling All Programs Installed

homebrewmacos

I am wondering if there is a way to uninstall all "programs" installed by Homebrew? I was using it and installed programs that corresponded to programming or using C/C++ and used the terminal to compile it but will not be using it in a few months.

Best Answer

According to the homebrew FAQ, to uninstall homebrew you use:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

If you don’t want to completely uninstall home-brew but just want to remove all packages installed by homebrew, I think this will do what you need (I’m not currently in a position to remove all of my packages to check):

#Loop while there are still package installed
while [[ `brew list | wc -l` -ne 0 ]]; do
    #Interate over each installed package
    for EACH in `brew list`; do
        #Uninstall each package
        brew uninstall $EACH --force
    done
done

I’ve enclosed the whole thing in a loop double check that after the first run all of the packages have been uninstalled—I’m pretty sure they will be due to the --force option, but belt and braces...