Homebrew
Homebrew is the package manager for macOS and is an essential tool for any developer.
Prerequisites
Verify installation of Command Line Tools for Xcode
sudo xcode-select --installInstall
The ~/.zshrc doesn’t exist by default in macOS, so you need to create it.
Go to Terminal and run:
touch ~/.zshrcNot install brew from Terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"For first time only, run following commands
This will create
~/.zprofilefile if it not exists or appendeval "$(/opt/homebrew/bin/brew shellenv)"line to existing~/.zprofilefile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"Once the installation is successful, run the following command:
brew doctorIf you get Your system is ready to brew., you can move on to the next step.
Brew anonymously collect User Behaviour data. To prevent analytics from ever being sent, run:
Homebrew Shell Completion
Brew installs completions and functions into: /opt/homebrew/share/zsh/site-functions when a formula offers them.
Shell completions for external Homebrew commands are not automatically installed. To opt-in to using completions for external commands (if provided), they need to be linked to HOMEBREW_PREFIX by running brew completions link.
To make Homebrew’s completions available in zsh, you must insert the Homebrew-managed zsh/site-functions path into your FPATH before initialising zsh’s completion facility. Add the following to your ~/.zshrc:
Note that, this snippet must be added in the top if
~/.zshrc
non-admin
[!CAUTION] Installing homebrew in non-standared location like below, will cause some packages not work properly.
If you don't have admin/sudo access to your laptop(e.g., company issued laptop), recomend installing brew in your home directory. In this case follow these steps
Then add brew to front of PATH by editing your shell profile file: .zprofile and adding below line:
Usage
Troubleshooting:
Example usage:
Homebrew keeps older versions of formulas installed on your system, in case you want to roll back to an older version. That is rarely necessary, so you can do some cleanup to get rid of those old versions:
Last updated
Was this helpful?