Skip to content

Instantly share code, notes, and snippets.

@zackintosh
Last active December 18, 2015 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackintosh/5851654 to your computer and use it in GitHub Desktop.
Save zackintosh/5851654 to your computer and use it in GitHub Desktop.
Fixes homebrew's taps when they are reported as broken when running "brew doctor" (eg. "Error: Failed to import: bonjour-browser"). This seems to happen often when the cask (https://github.com/phinze/homebrew-cask) tap has been tapped.
#/usr/bin/env bash
# Fix homebrew taps and simlinks
brewDir=$(brew --prefix)
taps=($(brew tap)) #Save off the current taps into an array
# Untap everything
for i in "${taps[@]}"
do
printf "Untapping: $i\n"
brew untap $i 2>&1 | sed "s/^/ /"
printf "\n"
done
printf "Removing all tap formula directories and deleting all symlinks..."
rm -rf $brewDir/Library/Taps/*
find $brewDir/Library/Formula -type l -delete
printf "\n Done.\n\n"
for i in "${taps[@]}"
do
printf "Restoring tap: $i\n"
brew tap $i 2>&1 | sed "s/^/ /"
printf "\n"
done
printf "Checking for updates...\n"
brew update 2>&1 | sed "s/^/ /"
printf "\nChecking with the brew doctor...\n"
brew doctor 2>&1 | sed "s/^/ /"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment