You can build Bazel from source without using an existing Bazel binary by doing the following:
sudo apt-get install build-essential openjdk-8-jdk python zip
Download bazel-<version>-dist.zip
from the release page.
Note: There is a single, architecture-independent distribution archive. There are no architecture-specific or OS-specific distribution archives.
We recommend to also verify the signature made by our release key 48457EE0.
The distribution archive contains generated files in addition to the versioned sources, so this step cannot be short cut by checking out the source tree.
./compile.sh
.cd
into the directory where you unpacked the distribution archivebash ./compile.sh
cd
into the directory where you unpacked the distribution archive./compile.sh
Once you have a Bazel binary, you no longer need to use the MSYS2 shell. You can run Bazel from the Command Prompt (cmd.exe
) or PowerShell.
The output will be output/bazel
on Unix-like systems (e.g. Ubuntu, macOS) and output/bazel.exe
on Windows. This is a self-contained Bazel binary. You can copy it to a directory on the PATH
(such as /usr/local/bin
on Linux) or use it in-place.
JAVA_HOME
environment variable to the JDK's directory.For example in the Windows Command Prompt (cmd.exe
):
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112
Note: do not use quotes (") around the path like you would on Unix. Windows doesn't need them and they may confuse Bazel.
This step is not required if you downloaded a binary distribution of Bazel or installed Bazel using Chocolatey. See installing Bazel on Windows.