1.. _docs-install-bazel: 2 3============= 4Install Bazel 5============= 6This page provides recommendations on how to install Bazel 7for Bazel-based Pigweed projects. 8 9.. _docs-install-bazel-bazelisk: 10 11----------------------------------- 12CLI commands: bazelisk versus bazel 13----------------------------------- 14Pigweed recommends always running ``bazelisk`` rather than ``bazel`` because 15``bazelisk`` ensures that you always run the correct Bazel version defined in 16your project's ``.bazelversion`` file. 17 18----------------- 19Recommended setup 20----------------- 21If you use Visual Studio (VS) Code, Pigweed's VS Code extension can manage 22Bazel for you: 23 24.. _Pigweed extension: https://marketplace.visualstudio.com/items?itemName=pigweed.pigweed-vscode 25 26#. Get `VS Code <https://code.visualstudio.com/download>`_. 27#. Install the `Pigweed extension`_ for VS Code. 28 29------------------ 30Alternative setups 31------------------ 32 33.. _Bazelisk release: https://github.com/bazelbuild/bazelisk/releases 34 35.. _Bazelisk repo: https://github.com/bazelbuild/bazelisk 36 37.. tab-set:: 38 39 .. tab-item:: Linux 40 :sync: linux 41 42 .. caution:: 43 44 Most Linux distributions don't have a recent version of Bazelisk 45 in their software repositories, or they don't have it at all. 46 47 Install from a binary release: 48 49 #. Get the latest `Bazelisk release`_. 50 51 #. Add the binary to your ``PATH``. 52 53 Install from source: 54 55 #. Install `Go <https://go.dev/doc/install>`_. 56 57 #. Clone the source: 58 59 .. code-block:: 60 61 go install github.com/bazelbuild/bazelisk@latest 62 63 #. Add the Go binaries to your ``PATH``: 64 65 .. code-block:: 66 67 export PATH=$PATH:$(go env GOPATH)/bin 68 69 .. tab-item:: macOS 70 :sync: macos 71 72 (Recommended) `Homebrew <https://brew.sh/>`_: 73 74 .. code-block:: 75 76 brew install bazelisk 77 78 `MacPorts <https://www.macports.org/install.php>`_: 79 80 .. code-block:: 81 82 sudo port install bazelisk 83 84 .. tab-item:: Windows 85 :sync: windows 86 87 (Recommended) `winget <https://learn.microsoft.com/en-us/windows/package-manager/winget/>`_: 88 89 .. code-block:: 90 91 winget install --id=Bazel.Bazelisk -e 92 93 `Chocolatey <https://chocolatey.org/install>`_: 94 95 .. code-block:: 96 97 choco install bazelisk 98