layout: documentation title: Compile Bazel from Source

Compile Bazel from source

On Linux or macOS

  1. Ensure that you have OpenJDK 8 installed on your system. For a system based on debian packages (e.g. Debian, Ubuntu), install OpenJDK 8 by running the command sudo apt-get install openjdk-8-jdk.

  2. The standard way of compiling a release version of Bazel from source is to use a distribution archive. Download bazel-<VERSION>-dist.zip from the release page for the desired version. We recommend to also verify the signature made by our release key 48457EE0. The distribution archive also contains generated files in addition to the versioned sources, so this step cannot be short cut by using a checkout of the source tree.

  3. Unzip the archive and call bash ./compile.sh; this will create a bazel binary in output/bazel. This binary is self-contained, so it can be copied to a directory on the PATH (such as /usr/local/bin) or used in-place.

On Windows

Windows support is in beta. Known issues are marked with label “Windows” on github issues.

Prerequisites:

To build Bazel on Windows:

  • Open the msys2 shell.
  • Clone the Bazel git repository as normal.
  • Run compile.sh in Bazel directory.
  • If all works fine, Bazel will be built at output\bazel.exe.