Install Bazel#

This page provides recommendations on how to install Bazel for Bazel-based Pigweed projects.

Bazel versus Bazelisk#

On pigweed.dev you’ll see references to both Bazel and Bazelisk. Bazel is an open-source, multi-language, multi-platform build and test tool similar to Make. Bazelisk is the official CLI launcher for Bazel. Here’s a summary from the Bazelisk repository:

Bazelisk is a wrapper for Bazel written in Go. It automatically picks a good version of Bazel given your current working directory, downloads it from the official server (if required) and then transparently passes through all command-line arguments to the real Bazel binary. You can call it just like you would call Bazel.

On the command line, you should always invoke bazelisk, not bazel.

Alternative setups#

Caution

Most Linux distributions don’t have a recent version of Bazelisk in their software repositories, or they don’t have it at all.

Install from a binary release:

  1. Get the latest Bazelisk release.

  2. Add the binary to your PATH.

Install from source:

  1. Install Go.

  2. Clone the source:

    go install github.com/bazelbuild/bazelisk@latest
    
  3. Add the Go binaries to your PATH:

    export PATH=$PATH:$(go env GOPATH)/bin
    

(Recommended) Homebrew:

brew install bazelisk

MacPorts:

sudo port install bazelisk

(Recommended) winget:

winget install --id=Bazel.Bazelisk  -e

Chocolatey:

choco install bazelisk