How to Install Bazel on macOS
Overview
Bazel is a free, open-source build system that is designed to handle large, complex projects. It can be used to build a variety of languages including Java, C++, and Python among others. This tutorial will guide you through the process of installing Bazel on macOS.
Prerequisites
Before you proceed, ensure that you have the following installed on your macOS:
- Terminal or a Command Line Interface
- Xcode Developer Tools
- Homebrew
Steps
- Open Terminal or your Command Line Interface.
- Install Xcode Developer Tools by running the following command:
xcode-select --install
- Install Homebrew if you have not yet done so, via the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Once Homebrew is installed, update it by running the following command:
brew update
- Install the required dependencies by running:
brew install [email protected]
brew install openjdk@11
- Add the OpenJDK version 11 to your PATH by running the following command:
echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
- Reload the terminal by executing:
source ~/.zshrc
- Verify that the latest Python 3 has been installed on your system by running:
python3 --version
- Install Bazel by running the following command:
brew install bazel
- To confirm that Bazel has been installed, check the version of Bazel by running:
bazel version
Conclusion
You have now successfully installed Bazel on your macOS. You can now begin to use Bazel to build your projects.