What is brew?
Brew or Homebrew is a package manager. Similar to Gentoo's emerge, or Ubuntu's apt.
What does it do?
Homebrew installs stuff you need that Apple didn’t. Installs packages to their own directory and then symlinks their files into /usr/local. Packages are called
formulae and repositories are called
Terminal and type:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To search for a specific package type:
brew search STRING
To search keywords only in the package's description:
brew desc -s STRING
Or to search both, package names and the description:
brew desc -d STRING
Installing / Removing packages
brew install PACKAGE_NAME brew remove PACKAGE_NAME
Updating package list and packages
Packages change all the time. To make sure the list of packages and their versions is updated run this:
List outdated packages:
Upgrade all outdated packages:
To prevent a specific package from upgrading when you issue a
brew upgrade you can "pin" it with:
brew pin PACKAGE
Or unpin it with:
brew unpin PACKAGE
Linking / Unlinking packages:
Usually not needed, but sometime is so... ;)
To link, that is, create symlinks to the package's binaries in the
brew link PACKAGE
And to unlink the package:
brew unlink PACKAGE
Removing dead symlinks from the Homebrew prefix:
List all installed packages:
List installed packages that are not dependencies of another installed package:
List package's dependancies:
brew deps PACKAGE
List package's dependancies as a tree:
brew deps --tree PACKAGE
Taps (repositories) Add / Remove / List
brew tap TAP/NAME
brew untap TAP/NAME
List all linked taps:
rmtree command (external)
It's an external command for Homebrew that provides a new command, rmtree, that will uninstall that formula, and uninstall any of its dependencies that have no formula left installed that depend on them.
Tap this repository and install via brew itself.
brew tap beeftornado/rmtree
Removing "lost" packages
Currently Homebrew doesn’t have any kind of feature like apt’s autoremove to remove unused dependencies — brew doesn’t make a distinction between packages explicitly installed by the user and those installed as dependencies.
Luckily for all of us Connor Worley has written a script that iterates through all packages that aren’t being depended on and asks if you want to keep or remove them.
It depends on
fish shell, so install it first:
brew install fish
#!/usr/bin/env fish set -l visited_formulas 'brew-cask' function check_formulas for formula in $argv set -l dependees (brew uses --installed $formula) if [ -z "$dependees" ]; and \ not contains $formula $visited_formulas read -p "echo \"$formula is not depended on by other formulas. Remove? [Y/n] \"" -l input set visited_formulas $visited_formulas $formula if [ "$input" = "Y" ] brew remove $formula check_formulas (brew deps --1 --installed $formula) end end end end echo "Searching for formulas not depended on by other formulas..." check_formulas (brew list)
Checking Build Options
You can check the options/flags the install will be done with by issuing this command:
brew options fish
Editing Build Options
If you need to install the package with different options you can try to edit the config file for it:
brew edit fish
Removes any older versions and deletes old downloads from the Homebrew download-cache:
Check for brew errors
Show Homebrew and system configuration useful for debugging.
As far as I know there is only one GUI frontend for brew, it's called
Cakebrew. You can download it here: https://www.cakebrew.com/