12 July, 2017
A quick one today. Setting up a new machine is always fun, and I tend to use Homebrew to manage what is installed. I've always found that to be a solution with diminishing returns, as it's easy to lose track of what's been installed over time.
The usual tool for this has been
brew list, which will show you everything installed via Homebrew. The output of ths really does list everything installed, not just the things you've requested. For example, maybe I want to install
foo, so I type:
$ brew install foo
I then have a look at what's installed and get:
$ brew list foo bar baz
baz come from? They're required for
foo to work, so Homebrew installed them for me. Nice. Weeks later I decide
foo isn't for me, so I get rid of it:
$ brew uninstall foo $ brew list bar baz
Huh? What gives? Homebrew hasn't uninstalled the dependencies. This is actually expected behaviour, as maybe I'm using
baz on their own. Uninstalling
foo doesn't tell Homebrew whether I still need the dependencies or not, so it plays it safe.
The point is that
brew list tells me what's installed, not what I installed. To keep track of this, I use Ansible to manage what's installed via
brew, so at any time I can see what I've requested. It's not perfect though (as I can still use
brew install at any point). I'd given up on keeping solid track of what I'd installed on my machine over time.
Until today, that is. Today I learned about
brew leaves. Yes people, I'm here to spread the good word that Homebrew can, in fact, keep track of its installation history:
$ brew install foo $ brew list foo bar baz $ brew leaves foo $ brew install baz $ brew leaves foo baz