Or you may want to see the dependencies for all installed formulae:
$ brew deps --installed
apr:
apr-util: apr openssl
autoconf:
automake: autoconf
boost:
boost-python: boost
cmake:
cockroach:
go-delve/delve/delve:
eigen:
fontconfig: freetype libpng
freetype: libpng
gd: fontconfig freetype jpeg libpng libtiff webp
gettext:
gflags:
glog: gflags
go:
gperftools:
graphviz: fontconfig freetype gd jpeg libpng libtiff libtool webp
hdf5: gcc gmp isl libmpc mpfr szip
ilmbase:
jpeg:
leveldb: gperftools snappy
libidn2: gettext libunistring
libpng:
libtiff: jpeg
libtool:
libunistring:
links: openssl
lmdb:
nmap: openssl
numpy: gdbm openssl python readline sqlite xz
opencv: eigen ffmpeg gdbm ilmbase jpeg libpng libtiff numpy openexr openssl python
python@2 readline sqlite tbb xz
openexr: ilmbase
openssl:
pcre:
perl:
pkg-config:
readline:
scons:
snappy:
sqlite: readline
subversion: apr apr-util openssl perl sqlite
swig: pcre
szip:
webp: jpeg libpng
wget: gettext libidn2 libunistring openssl
Troubleshoot Homebrew
Many utilities can be installed using Homebrew as well as with another method, such as a PKG installer or a DMG disk image. There are potential dangers when you use multiple installation methods. If you don’t pay attention, or you don’t remember what you did the last time (my hand is up for that one), you can wind up with multiple copies of a program in different locations. The first searched path that has the program is the one that will run: you may want to uninstall one of the copies.
You can find out the location of the copy that will run with the which
command, for example which go
. You can get the full information with ls
, for example ls -l `which go`
. If the copy you want to uninstall was installed with Homebrew, you can delete it with brew uninstall <name>
, for example brew uninstall go
.
Brew doesn't delete old versions by default when you install new versions. To delete all brewed versions of one particular program, use the --force
flag, for example brew uninstall --force go
.
To delete all old versions for all installed formulae, you can use brew cleanup
. You'll see something like this:
$ brew cleanup
Warning: Skipping automake: most recent version 1.16.1_1 not installed
Warning: Skipping boost: most recent version 1.67.0_1 not installed
Warning: Skipping boost-python: most recent version 1.67.0 not installed
Warning: Skipping cmake: most recent version 3.12.1 not installed
Warning: Skipping cockroach: most recent version 2.0.5 not installed
Removing: /usr/local/Cellar/delve/0.12.1... (6 files, 8MB)
Warning: Skipping eigen: most recent version 3.3.5 not installed
Warning: Skipping fontconfig: most recent version 2.13.0 not installed
Warning: Skipping freetype: most recent version 2.9.1 not installed
Warning: Skipping gd: most recent version 2.2.5 not installed
Warning: Skipping gflags: most recent version 2.2.1 not installed
Warning: Skipping glog: most recent version 0.3.5_3 not installed
Warning: Skipping gperftools: most recent version 2.7 not installed
Removing: /usr/local/Cellar/graphviz/2.38.0_1... (506 files, 67.0MB)
Warning: Skipping hdf5: most recent version 1.10.3 not installed
Warning: Skipping ilmbase: most recent version 2.2.1 not installed
Warning: Skipping jpeg: most recent version 9c not installed
Warning: Skipping leveldb: most recent version 1.20_2 not installed
Warning: Skipping libpng: most recent version 1.6.35 not installed
Warning: Skipping libtiff: most recent version 4.0.9_4 not installed
Warning: Skipping lmdb: most recent version 0.9.22 not installed
Warning: Skipping numpy: most recent version 1.15.1 not installed
Warning: Skipping opencv: most recent version 3.4.2 not installed
Warning: Skipping openexr: most recent version 2.2.0_1 not installed
Removing: /usr/local/Cellar/openssl/1.0.2j... (1,695 files, 12MB)
Removing: /usr/local/Cellar/openssl/1.0.2n... (1,792 files, 12.3MB)
Removing: /usr/local/Cellar/openssl/1.0.2o_1... (1,791 files, 12.3MB)
Warning: Skipping perl: most recent version 5.28.0 not installed
Removing: /usr/local/Cellar/pkg-config/0.29.1_2... (10 files, 627.4KB)
Warning: Skipping readline: most recent version 7.0.5 not installed
Warning: Skipping snappy: most recent version 1.1.7_1 not installed
Warning: Skipping sqlite: most recent version 3.24.0 not installed
Warning: Skipping subversion: most recent version 1.10.2 not installed
Removing: /Users/martinheller/Library/Caches/Homebrew/subversion--serf-1.3.9.tar.bz2... (141.7KB)
Warning: Skipping szip: most recent version 2.1.1_1 not installed
Warning: Skipping webp: most recent version 1.0.0 not installed
Removing: /Users/martinheller/Library/Caches/Homebrew/openssl-1.0.2n.high_sierra.bottle.tar.gz... (3.7MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/readline-7.0.3_1.high_sierra.bottle.tar.gz... (495.5KB)
Removing: /Users/martinheller/Library/Caches/Homebrew/cockroach-1.1.3.high_sierra.bottle.tar.gz... (21MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/sqlite-3.23.0.high_sierra.bottle.tar.gz... (1.4MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/perl-5.26.1.high_sierra.bottle.1.tar.gz... (15.3MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/openssl-1.0.2o_1.high_sierra.bottle.tar.gz... (3.7MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/subversion-1.9.7.tar.bz2... (7.5MB)
Removing: /Users/martinheller/Library/Caches/Homebrew/go-1.10.3.high_sierra.bottle.tar.gz... (102.6MB)
Removing: /Users/martinheller/Library/Logs/Homebrew/pkg-config... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/go... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/swig... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/boost... (6 files, 19.8MB)
Removing: /Users/martinheller/Library/Logs/Homebrew/apr-util... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/perl... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/scons... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/readline... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/delve... (3 files, 57.9KB)
Removing: /Users/martinheller/Library/Logs/Homebrew/sqlite... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/fontconfig... (910B)
Removing: /Users/martinheller/Library/Logs/Homebrew/boost-python... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/apr... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/cockroach... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/pcre... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/nmap... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/openssl... (64B)
Removing: /Users/martinheller/Library/Logs/Homebrew/subversion... (17 files, 1.4MB)
Removing: /Users/martinheller/Library/Logs/Homebrew/protobuf... (15 files, 1.5MB)
==> This operation has freed approximately 291MB of disk space.
All of those warnings mean that I didn’t upgrade some of my installed brews. I can fix that, first by updating Homebrew to have a current catalog, and then by upgrading all brews:
$ brew update
Updated 2 taps (homebrew/core, homebrew/cask).
==> Updated Formulae
crystal influxdb thors-serializer
fortio juju youtube-dl
Martins-Retina-MacBook:~ martinheller$ brew upgrade
==> Upgrading 29 outdated packages, with result:
libtiff 4.0.7 -> 4.0.9_4, leveldb 1.19 -> 1.20_2, ilmbase 2.2.0 -> 2.2.1, libpng 1.6.27 -> 1.6.35, cmake 3.7.1 -> 3.12.1, freetype 2.7.1 -> 2.9.1, hdf5 1.8.18 -> 1.10.3, boost 1.63.0 -> 1.67.0_1, perl 5.26.1 -> 5.28.0, readline 7.0.3_1 -> 7.0.5, glog 0.3.4_1 -> 0.3.5_3, webp 0.5.2 -> 1.0.0, sqlite 3.23.0 -> 3.24.0, eigen 3.3.1 -> 3.3.5, numpy 1.11.2 -> 1.15.1, openexr 2.2.0 -> 2.2.0_1, fontconfig 2.12.1_2 -> 2.13.0, gflags 2.2.0 -> 2.2.1, boost-python 1.63.0 -> 1.67.0, lmdb 0.9.19 -> 0.9.22, opencv 2.4.13.2 -> 3.4.2, gperftools 2.5 -> 2.7, snappy 1.1.3 -> 1.1.7_1, gd 2.2.3_1 -> 2.2.5, cockroach 1.1.3 -> 2.0.5, jpeg 8d -> 9c, szip 2.1 -> 2.1.1_1, subversion 1.9.7_3 -> 1.10.2, automake 1.15 -> 1.16.1_1
==> Upgrading readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.5.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline--7.0.5.high_sierra.bottle.tar.gz
…
By the way, the brew upgrade
step was lengthy on my machine. One issue was that hdf5
, which is a prerequisite for the deep learning package Keras (itself installed with pip
, not brew
), has a dependency of gcc
, the Gnu C++ compiler. Amusingly, or annoyingly, depending on your point of view, the gcc
installation on MacOS requires the Xcode Command Line Tools — in other words, you need a working Apple C++ compiler to build the Gnu C++ compiler. The process was slowed down significantly by the antivirus scan that was running, which must have been triggered by all the new downloads. I should have run the upgrade overnight or during a meal.
As the late Jerry Pournelle used to say, we do stupid stuff so that you don’t have to.
Once the upgrade completed, I re-ran the cleanup and freed another 900 MB of disk space. Then I checked my installation with brew doctor
, which discovered a few actual problems in addition to warning about many benign conditions. I then ran brew prune
to get rid of broken symlinks, and brew install
with a list of missing dependencies.
Homebrew bottles, casks, and taps
Homebrew can install formulae two ways: by building from source code (often time-consuming) or by unpacking and installing (pouring) from a binary bottle. Bottles are gzipped tarballs of compiled binaries. Any metadata is stored in a formula’s bottle DSL and in the bottle filename (i.e. MacOS version, revision). You can see that in action in the printouts above, for example the readline
installation, which pours readline--7.0.5.high_sierra.bottle.tar.gz
.
By default, Homebrew formulae come from the core list. If you want to use other repositories of formulae, called taps, you can add them with brew tap <user/repo>
.
Homebrew casks are command-line binary installers for apps that aren’t in the Mac App Store. There are currently about four thousand of them, but they aren’t in the Homebrew formulae list. Instead they can be found in the shell with brew search
. For example, you can find all formulae and casks whose name contains “chrome” with this command:
$ brew search chrome
==> Formulae
chrome-cli chrome-export
==> Casks
chrome-devtools google-chrome
chrome-remote-desktop-host mkchromecast
chromedriver homebrew/cask-versions/google-chrome-beta
dmm-player-for-chrome homebrew/cask-versions/google-chrome-canary
epichrome homebrew/cask-versions/google-chrome-dev
The prefix homebrew/cask-versions/
refers to the tap for alternate versions of casks. The cask google-chrome
is the current production version of Chrome; homebrew/cask-versions/google-chrome-canary
is the “canary” channel version of Chrome, for early adopters and testers. You can add a tap hosted on GitHub with brew tap <user/repo>
, add a Git repository hosted somewhere else using the URL, and remove a tap with brew untap <name>
.
If you wish, you can create your own Homebrew formulae and casks. It’s quite easy if you are familiar with Ruby and Git. The developer commands are listed several pages into the Homebrew manual man brew
. Additional information, sample code, and tools can be found in the online Homebrew documentation.