Skip to main content
Bazel can be installed in a few ways, you’ll learn about them in this section. After successful installation, you should be able to run the bazel command in your terminal.
Check with your team first: Some companies have specific Bazel setups managed by their Dev Infra team. Make sure you don’t accidentally override your company’s configuration.

Installation via starter template

The fastest way to get started is using GitHub Codespaces, which comes with Bazel pre-installed via Bazelisk. No manual installation required. To get started, we’ll use the Shell starter template. You can create a new Bazel project using one of these methods. Option A allows you to create a permanent project, while option B gives you a playground to experiment with.

Option A: Create a new repository

  1. Click on the use a template green button at the top right corner of the starter repository.
  2. Select create a new repository from the drop menu.
  3. Pick a name for your new repository.
  4. Click Create repository and you will be redirected to your new repository with the bazel template.
  5. Press , (comma key) on your keyboard to open the project in a Github codespace.
GitHub Codespaces comes with Bazel preinstalled via Bazelisk, so no manual Bazel installation is required.

Option B: Test on a remote playground

  1. Click on the use a template green button at the top right corner of the starter repository.
  2. Select open in codespace to open the project in a GitHub codespace.
Once you’re in the codespace, wait for a few minutes for the machine to boot up. And ignore any errors in the terminal as they will be resolved once all the setup scripts run to completion.
By default, the codespaces are launched in a smaller machine. For a faster and more responsive development experience, create a codespace with a larger machine.

Installation via Bazelisk

Bazel installation via Bazelisk is highly recommended by the team at Google. Bazelisk provides:
  • A version-aware wrapper for Bazel
  • Automatic resolution and installation of the Bazel version specified in the project’s .bazelversion file
  • Consistent Bazel versions across developer environments and CI, preventing version drift
It is common practice for developers to rename Bazelisk to Bazel on their path, so they don’t need to think about the distinction. To get started, we’ll use the Bazel shell starter template that is setup in a codelab environment that uses Bazelisk.
The plain shell scripting is used here, because students of the 101 course might be unfamiliar with any language we pick
starter

Installation via Aspect CLI

This course uses the Aspect CLI as a wrapper for bazel and it has features that make Bazel easier to learn; such as improved output from bazel help and added commands like bazel lint, while remaining fully backwards-compatible with vanilla Bazel. You are free to go back to vanilla Bazel anytime.

Install with Homebrew (macOS)

To install via Homebrew, run the following command:
You can use the Aspect CLI together with Bazelisk. Bazelisk reads a .bazeliskrc file that is checked into your repository, which lets your team share the same Bazel setup. When this file is present, any engineer who runs bazel (which is usually Bazelisk on their machine) automatically gets the Aspect CLI features, without installing anything extra themselves.

Try it

Let’s confirm that Bazel is installed. Run bazel help to get familiar with it. You may also run bazel version to verify the installation. If you prefer not to run commands yourself, follow along with the instructor to see all the exercises presented.
Don’t worry if your team doesn’t use the Aspect CLI. This course works with vanilla Bazel, we’ll clearly mark any Aspect-specific features and show you the alternatives.
Here is a detailed guide to installing Aspect CLI in different environments.

Installation via Binary downloads

Bazel publishes release binaries, which are assets you can download directly from the GitHub releases.
  1. Download the binary file.
  2. Rename the binary file to bazel.
  3. Add it to your PATH.
  4. On macOS: Run xattr -c $(which bazel) to remove the Unknown Developer warning
This approach is not recommended. You’ll run a different Bazel version than your teammates and CI, causing hard-to-debug errors when the repo version changes.