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
.
Recommended setup#
If you use Visual Studio (VS) Code, Pigweed’s VS Code extension can manage Bazel for you:
Get VS Code.
Install the Pigweed extension for VS Code.
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:
Get the latest Bazelisk release.
Add the binary to your
PATH
.
Install from source:
Install Go.
Clone the source:
go install github.com/bazelbuild/bazelisk@latest
Add the Go binaries to your
PATH
:export PATH=$PATH:$(go env GOPATH)/bin