I recently had an issue where all of my linked binaries were removed from /usr/local/bin/. Fortunately, most of these were just dynamic links to binaries installed with Homebrew, so after reinstalling Homebrew I need to get them back. Is there a way to force reinstall all installed packages and binaries with Homebrew? Maybe piping the output of brew list into brew reinstall?

6 Answers 6


It's as simple as that:

$ brew list | xargs brew reinstall

You don't need to uninstall anything, because doing so you may lose your settings and configs.

  • I had to remove a few problem formulae, but this did the trick. Thanks!
    – JAL
    Nov 13, 2016 at 2:38
  • 1
    works except for casks Feb 1, 2019 at 14:59
  • 6
    The maintainers of HomeBrew now recommend adding --formula to only list formulae, making the updated command $ brew list --formula | xargs brew reinstall (as of November 2020). Nov 16, 2020 at 5:48
  • Does anyone know if running the brew uninstall script will delete the casks that were installed by homebrew? I know that running "brew uninstall --cask [caskname]" will delete the cask, but the uninstall script doesn't say whether it will delete all the installed casks as well.
    – Jason
    Dec 29, 2020 at 22:05

to keep not only installed brews but also casks and taps i recommend to

$ brew bundle dump --describe --global
$ brew bundle install --global

the first command will write ~/.Brewfile which will be read again in the second call. it looks like this:

$ cat ~/.Brewfile
tap "buo/cask-upgrade"
tap "homebrew/cask-fonts"
brew "direnv"
brew "python"
cask "0xed"
cask "alacritty"

please issue

$ brew bundle -h

for more details on the bundle command.


I ran into a need for this after upgrading to OSX High Sierra. Most of the brew packages were failing form missing dylibs. Ended up writing a quick & dirty script that cleanly removes & replaces one at a time, ignoring dependencies so you don't force bulk purges. You need to fix each stopping point, but it picks up where it left off so it's not too painful.

YMMV as always

#!/bin/bash -e
if [ "$1" == "-h" ] ; then
    cat <<EOT
    Remove & reinstall all brew owned packages
    Fail on error to allow manual fixing
    Accept package name as arg1 to spec pick up point.
        $0 [<pickup point>]
        $0 ctags
            where <ctags> is the package to start from
    exit 1

for l in $(brew list) ; do
    if [ "$1" ] ; then
        if [[ $l < $1 ]] ; then
            echo "skipping $l"
    echo "Remove $l"
    brew uninstall --ignore-dependencies $l 
    echo "Re-add $l"
    brew install $l

You can remove all packages first, then install all again....

$ brew tap beeftornado/rmtree && brew install brew-rmtree
$ brew rmtree <package>
  • I could, but then I would have to manually enter every package name from brew list. I need an automated solution that automatically pulls from brew list and reinstalls all packages.
    – JAL
    Oct 22, 2016 at 15:24

Something like

cd /tmp
brew list -1 >brew-list
# do whatever is necessary to remove packages
while read package; do
    brew install $package
done <brew-list

should do the trick (unless you've installed from taps then it may need some more work).


For me it was better to remove all and then install all, because of many errors that existed still when just reinstalling, due to transitive dependencies.

Potentially the brew reinstall approach, but only if the packages are reinstalled in a certain order (first packages that do not depend on other packages, and then packages that depend only on packages freshly reinstalled) - this may be an option to keep configs.

Still i found cleaner in my case to proceed with uninstall all and install all:

brew list --formula > formulas
brew uninstall $(cat formulas)
for i in $(cat formulas); do brew install $i ; done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .