Install Bazel on macOS using one of the following methods:
Bazel comes with two completion scripts. After installing Bazel, you can:
The binary installers are on Bazel's GitHub releases page.
The installer contains the Bazel binary.1 Some additional libraries must also be installed for Bazel to work.
Xcode can be downloaded from the Apple Developer Site (this link redirects to their App Store).
For objc_*
and ios_*
rule support, you must have Xcode 6.1 or later with iOS SDK 8.1 installed on your system.
Once Xcode is installed, accept the license agreement for all users with the following command:
sudo xcodebuild -license accept
Next, download the Bazel binary installer named bazel-<version>-installer-darwin-x86_64.sh
from the Bazel releases page on GitHub.
Run the Bazel installer as follows:
chmod +x bazel-<version>-installer-darwin-x86_64.sh ./bazel-<version>-installer-darwin-x86_64.sh --user
The --user
flag installs Bazel to the $HOME/bin
directory on your system and sets the .bazelrc
path to $HOME/.bazelrc
. Use the --help
command to see additional installation options.
If you ran the Bazel installer with the --user
flag as above, the Bazel executable is installed in your $HOME/bin
directory. It's a good idea to add this directory to your default paths, as follows:
export PATH="$PATH:$HOME/bin"
You can also add this command to your ~/.bashrc
or ~/.profile
file.
All set! You can confirm Bazel is installed successfully by running the following command:
bazel --version
To update to a newer release of Bazel, download and install the desired version.
Install Homebrew (a one-time step):
/usr/bin/ruby -e "$(curl -fsSL \ https://raw.githubusercontent.com/Homebrew/install/master/install)"
Please note that if your system has the Bazel package from homebrew core installed you first need to uninstall it by typing brew uninstall bazel
Install the Bazel package via Homebrew as follows:
brew tap bazelbuild/tap brew install bazelbuild/tap/bazel
All set! You can confirm Bazel is installed successfully by running the following command:
bazel --version
Once installed, you can upgrade to a newer version of Bazel using the following command:
brew upgrade bazelbuild/tap/bazel