Homebrew
Install and configure Homebrew, the essential package manager for macOS that simplifies software installation
What is Homebrew?
Homebrew installs the stuff you need that Apple (or your Linux system) didnβt.
Homebrew installs packages to their own directory and then symlinks their files into
/usr/local(on macOS Intel). Homebrew wonβt install files outside its prefix and you can place a Homebrew installation wherever you like.
Essentially, this is a package manager that enables you to install a vast amount of different packages without leaving fragmented files all across your system.
Installation
Open a new terminal session and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installation completes, close your terminal session.
Before you continue, set up your ZSH / Oh My ZSH! foundation shell, then add Homebrew to your
~/.zshrcor~/.bashrcconfig file.
Installing Packages
Open a new terminal session.
Install the latest version:
brew install <package>
Install a specific version:
brew install <package>@<version>
Uninstalling Packages
brew uninstall <package>
Good to Know
Listing Available Packages
To see if the package you need is available through Homebrew:
brew search <package>
Switch Global Versions
# List installed versions of a package
brew list --versions <package>
# Unlink current version
brew unlink <package>
# Link specific version
brew link <package>@<version>
# Verify the switch worked
brew doctor
Note: The
brew switchcommand was deprecated in Homebrew 2.6.0 (December 2020). Useunlink+linkinstead.
Check Your Current Version
Check which version of a package is being used:
brew info <package>
API Rate Limit
Frequent requests to Homebrew may cause API rate limit timeout. Consider adding a GitHub API token to prevent this:
- Go to GitHub Personal Tokens
- Login with your GitHub account
- Set how long you want the token to be valid for (3 months, 6 months, etc.)
- Create your API token
- Add to your
~/.zshrcor~/.bashrcconfig file:
export HOMEBREW_GITHUB_API_TOKEN=<your_token_here>
Installed Packages
To know what packages you have installed with Homebrew:
brew deps --tree --installed
To view details of installed packages:
brew info <package-name>
This will also give you the location that the package is installed at.
Update Homebrew and Packages
brew update && brew upgrade
If you want, you can make this an alias in your .zshrc file:
alias update_homebrew='brew update && brew upgrade'
brew updateupdates the downloaded git repository with the latest code from GitHubbrew upgradeupdates the actual packages to match the versions in the updated local git repository
Troubleshooting
Symlink Issues
If you had installed other packages prior to installing Homebrew (such as Python from python.org), you may have some symlink issues.
Symbolic link (symlink) is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.
To fix these issues, you can run the below command and specify the package whose symlink you want to fix:
brew link --overwrite <package_name>
Resources
Official Homebrew documentation with installation guides and FAQ
Search for available packages and casks in the Homebrew ecosystem