LinuxCommandLibrary

brew-bundle

Install multiple Homebrew packages from a Brewfile

TLDR

Install packages from a Brewfile at the current path

$ brew bundle
copy

Install packages from a specific Brewfile at a specific path
$ brew bundle --file [path/to/file]
copy

Create a Brewfile from all installed packages
$ brew bundle dump
copy

Uninstall all formulae not listed in the Brewfile
$ brew bundle cleanup --force
copy

Check if there is anything to install or upgrade in the Brewfile
$ brew bundle check
copy

List all entries in the Brewfile
$ brew bundle list --all
copy

SYNOPSIS

brew bundle [install | dump | check | cleanup] [options]

PARAMETERS

install
    
(Default) Installs or upgrades all dependencies listed in the Brewfile.

dump
    
Generates a Brewfile from currently installed Homebrew packages, casks, and taps.

check
    
Checks if all items in the Brewfile are installed and up-to-date. Exits with 0 if true, 1 otherwise.

cleanup
    
Uninstalls Homebrew packages, casks, and taps that are not listed in the Brewfile.

--global / -g
    
Uses or creates the Brewfile at ~/.Brewfile instead of the current directory.

--file= / -f
    
Specifies an alternative path for the Brewfile.

--force
    
When used with dump, overwrites an existing Brewfile. With cleanup, performs cleanup without prompting.

--no-upgrade
    
During install, prevents upgrading already installed formulae/casks.

--no-install
    
During install, performs check and cleanup but does not install anything.

--dry-run
    
Simulates the operation without making actual changes (useful with install or cleanup).

--verbose / -v
    
Provides more detailed output during execution.

DESCRIPTION

brew bundle is a powerful Homebrew subcommand designed to manage software dependencies in a declarative and reproducible manner using a Brewfile. Similar to Gemfile for Ruby or package.json for Node.js, a Brewfile serves as a manifest listing formulae, casks, macOS App Store applications (via mas), taps, and even version control system repositories (repo) or Docker images (whalebrew). It streamlines the process of setting up a new development environment or migrating existing configurations by ensuring all specified software is installed. The command offers various subcommands like install (default, installs everything in Brewfile), dump (creates a Brewfile from currently installed packages), check (verifies if everything in Brewfile is installed), and cleanup (uninstalls packages not listed in Brewfile), making it a versatile tool for environment synchronization and maintenance.

CAVEATS

brew bundle relies on the proper formatting of the Brewfile. Incorrect syntax or unsupported directives will lead to errors. The cleanup subcommand can remove a significant amount of software; it is highly recommended to use --dry-run first to preview changes, especially in production or sensitive environments. While brew bundle can manage mas, repo, and whalebrew entries, it acts as an orchestrator and doesn't replace their underlying tools (e.g., you still need mas-cli for mas entries).

BREWFILE FORMAT

A Brewfile is a plain text file listing desired software. Common entry types include:

  • brew 'formula_name': For Homebrew formulae (e.g., git, wget).
  • cask 'application_name': For macOS applications (e.g., google-chrome, visual-studio-code).
  • tap 'user/tap_name': To add a third-party Homebrew tap (e.g., homebrew/cask-fonts).
  • mas 'App Name', id: APP_ID: For macOS App Store applications (requires mas-cli).
  • repo 'git_repository_url', branch: 'main': To clone a Git repository.
  • whalebrew 'docker_image': To manage whalebrew images (requires whalebrew).
Each line typically represents one dependency, providing a clear overview of the environment.

HISTORY

Homebrew, created by Max Howell, revolutionized package management on macOS. brew bundle emerged as a crucial extension, addressing the growing need for reproducible development environments. It started as an external command, homebrew/bundle, and was later integrated as a core subcommand, signifying its importance in the Homebrew ecosystem for managing complete software stacks from a single declarative file.

SEE ALSO

brew(1), brew install(1), brew cask(1), brew tap(1), mas(1)

Copied to clipboard