how to export your homebrew packages with brewfile

A practical guide to exporting and using a Brewfile for Homebrew package management on macOS.

how to export your homebrew packages with brewfile

If you use a Mac for development or productivity, chances are you rely on Homebrew to manage your software. But what if you want to back up your setup, share it with others, or quickly set up a new machine? That’s where the Brewfile comes in.

what is a brewfile?

A Brewfile is a simple text file that lists all your Homebrew packages, casks (apps), and taps; it’s like Manifest for your system’s software so you can easily reproduce your environment anywhere.

why export a brewfile?

  • Backup: Save a snapshot of your installed tools and apps.
  • Portability: Quickly set up a new Mac with the same packages.
  • Collaboration: Share your setup with teammates or the community.
  • Automation: Use in dotfiles or setup scripts for consistent environments.

how to export a brewfile

Exporting your current Homebrew setup is simple:

1
brew bundle dump --file=~/Brewfile --force
  • --file=~/Brewfile specifies the output location (default is ./Brewfile).
  • --force overwrites any existing Brewfile.

This command scans your system and reads all installed formulae, casks & taps to the Brewfile.

how to use a brewfile to restore packages

On a new Mac (or after if I clean install) To install everything listed in brewfile on .

1
brew bundle --file=~/Brewfile

The Brewfile will read the Brewerfile and install all specified packages, casks and taps.

tips and best practices

  • Version Control: Keep your Brewfile in your dotfiles repo for easy tracking and sharing.
  • Review Regularly: Occasionally review your Brewfile to remove unused packages.
  • Custom Brewfiles: You can create multiple Brewfiles for different projects or roles.

conclusion

I have a Brewfile (easy but powerful) and very strong way to back up, share/automate your macOS environment. Next time you set up i’m setting up another Mac then it will be up and running in minutes!

Built with Hugo
Theme Stack designed by Jimmy