.. _docs-install-bazel: ============= Install Bazel ============= This page provides recommendations on how to install Bazel for Bazel-based Pigweed projects. .. _docs-install-bazel-bazelisk: ----------------------------------- CLI commands: bazelisk versus bazel ----------------------------------- Pigweed recommends always running ``bazelisk`` rather than ``bazel`` because ``bazelisk`` ensures that you always run the correct Bazel version defined in your project's ``.bazelversion`` file. ----------------- Recommended setup ----------------- If you use Visual Studio (VS) Code, Pigweed's VS Code extension can manage Bazel for you: .. _Pigweed extension: https://marketplace.visualstudio.com/items?itemName=pigweed.pigweed-vscode #. Get `VS Code `_. #. Install the `Pigweed extension`_ for VS Code. ------------------ Alternative setups ------------------ .. _Bazelisk release: https://github.com/bazelbuild/bazelisk/releases .. _Bazelisk repo: https://github.com/bazelbuild/bazelisk .. tab-set:: .. tab-item:: Linux :sync: linux .. 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: .. code-block:: go install github.com/bazelbuild/bazelisk@latest #. Add the Go binaries to your ``PATH``: .. code-block:: export PATH=$PATH:$(go env GOPATH)/bin .. tab-item:: macOS :sync: macos (Recommended) `Homebrew `_: .. code-block:: brew install bazelisk `MacPorts `_: .. code-block:: sudo port install bazelisk .. tab-item:: Windows :sync: windows (Recommended) `winget `_: .. code-block:: winget install --id=Bazel.Bazelisk -e `Chocolatey `_: .. code-block:: choco install bazelisk