We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
If you are using a Mac as your development environment, you really should be using Brew. You probably should be using it if you are a power user as well, as it isn't really that difficult.
A key feature of Brew is its ability to set up your Mac to a known configuration. It does this a feature called Bundle that uses Brewfiles. As doing development, or experimenting with new apps can break your system, I can easily restore back to a known configuration, both on my primary Macs, but also in VMware Fusion instances where I do more testing, including testing on old versions of MacOS and new beta versions of MacOS.
A version of Brew also is available on Linux, but I mostly use apt-get on Debian. I am considering some cross-platform development scripts to use Brew instead.
Basic Brew Bundle
The most basic command
brew bundle install
Looks for ~/Brewfile
and installs its contents
Install a specific brewfile
If you want to use a brewfile from a non-standard place.
brew bundle --file=~/.private/Brewfile
Or more specifically:
brew bundle install --file=rs-brew-dump
Creating a Brewfile
You can dump a Brewfile of your current brew/cask/mas entries into your current directory with
brew bundle dump
or to a specific directory and file name.
brew bundle dump --file=~/.private/Brewfile
If a Brewfile already exists, you'll need to do
brew bundle dump --force
Cleaning up to match brewfile
If you want your current system configuration to match your brewfile
brew bundle --force cleanup
Best Practices: brew cask
, mas
and cu
A key practice is to install EVERYTHING possible using brew
, brew cask
, or mas
. Even things like fonts!
Three tools that really make this work for more than just development tools is the ability to install a large number of macOS UI apps using brew cask install <appname>
, Mac Apple Store apps using mas install <appnumber>
, search for them using brew search <searchterm>
& mas search <searchterm>
. Not everything is avaiable this way, but the most important ones are.
To use this make sure that these entries are near the top of your Brewfile
:
tap "homebrew/cask"
tap "buo/cask-upgrade"
brew "mas"
You even install many open source fonts this way. Do brew tap homebrew/cask-fonts" and Add this top the top of your
Brewfile`:
tap "homebrew/cask-fonts"
On can search for fonts once tapped by
brew search font
Finally, there is a Cask-Update tool that works with brew cask
to update all of your Mac apps.
Add this to your Brewfile
:
tap "buo/cask-upgrade"
Then to upgrade all of you Mac apps, just do:
brew cu
Cask-Update details some other features. In particular, I like brew cu pin <caskname>
which locks an app to a specific version.
Advanced Topics & To Investigate
-
Instead of
brew cask uninstall <caskname>
you can dobrew cask zap <caskname>
which may also do additional removal of preferences, caches, updaters, etc. stored in~/Library
. See Zap -
A pariculary powerful feature for Brew is that it attempts to install developer tools in ways that allow them to co-exist. However if you are using multiple versions of a tool, it can be difficult to understand dependencies. These links may help:
- brew deps
brew deps --tree <brewformula>
brew deps --tree -1 <brewformula>
brew deps --include-build --tree $(brew leaves)
- brew leaves
brew leaves | xargs brew deps --include-build --tree
brew leaves | xargs brew deps --installed --for-each | sed "s/^.*:/$(tput setaf 4)&$(tput sgr0)/"
brew leaves | sed 's/^/install /' > Brewfile
- brew graph
- A critique of
brew leaves
andbrew graph
- brew deps
-
If you are a heavy Github user, or are creating brew formulae, there is an advanced wrapper for Homebrew that automates the creation of the Brewfile and can store it on Github, along with a many more features: https://homebrew-file.readthedocs.io/
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.