- 22.04 (LTS)
- 20.04 (LTS)
- 18.04 (LTS)
- Recommended: Use Bazelisk
- Use our custom APT repository
- Use the binary installer
- Use the Bazel Docker container
- Compile Bazel from source
arm64
release, and there is no binary installer available. Either use Bazelisk or
compile from source.
Bazel comes with two completion scripts. After installing Bazel, you can:
- Access the bash completion script
- Install the zsh completion script
Using Bazel’s apt repository
Step 1: Add Bazel distribution URI as a package source
Note: This is a one-time setup step.Step 2: Install and update Bazel
bazel package always installs the latest stable version of Bazel. You
can install specific, older versions of Bazel in addition to the latest one,
such as this:
/usr/bin/bazel-1.0.0 on your system. This
can be useful if you need a specific version of Bazel to build a project, for
example because it uses a .bazelversion file to explicitly state with which
Bazel version it should be built.
Optionally, you can set bazel to a specific version by creating a symlink:
Step 3: Install a JDK (optional)
Bazel includes a private, bundled JRE as its runtime and doesn’t require you to install any specific version of Java. However, if you want to build Java code using Bazel, you have to install a JDK.Using the binary installer
Generally, you should use the apt repository, but the binary installer can be useful if you don’t have admin permissions on your machine or can’t add custom repositories. The binary installers can be downloaded from Bazel’s GitHub releases page. The installer contains the Bazel binary and extracts it into your$HOME/bin
folder. Some additional libraries must be installed manually for Bazel to work.
Step 1: Install required packages
Bazel needs a C++ compiler and unzip / zip in order to work:Step 2: Run the installer
Next, download the Bazel binary installer namedbazel-{{ '<var>' }}version{{ '</var>' }}-installer-linux-x86_64.sh
from the Bazel releases page on GitHub.
Run it as follows:
--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.
Step 3: Set up your environment
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:
~/.bashrc or ~/.zshrc file to make it
permanent.
Using the Bazel Docker container
We publish Docker container with Bazel installed for each Bazel version atgcr.io/bazel-public/bazel.
You can use the Docker container as follows: