blob: 453d5658dff9a7224547473c968abe51f21d1a07 [file] [log] [blame] [view]
Googler1fbef392017-03-22 09:05:09 +00001---
2layout: documentation
3title: Compile Bazel from Source
4---
5
6# <a name="compiling-from-source"></a>Compile Bazel from source
7
aehlig052c2dc2017-03-29 14:10:25 +000081. Ensure that you have OpenJDK 8 installed on your system.
Googler18a70dc2017-05-29 16:33:17 +02009 For a system based on debian packages (e.g. Debian, Ubuntu), install
aehlig052c2dc2017-03-29 14:10:25 +000010 OpenJDK 8 by running the command `sudo apt-get install openjdk-8-jdk`.
Googler1fbef392017-03-22 09:05:09 +000011
Googlerc82a1612017-03-28 12:56:57 +0000122. The standard way of compiling a release version of Bazel from source is to
13 use a distribution archive. Download `bazel-<VERSION>-dist.zip` from the
14 [release page](https://github.com/bazelbuild/bazel/releases) for the desired
15 version. We recommend to also verify the signature made by our
16 [release key](https://bazel.build/bazel-release.pub.gpg) 48457EE0.
Klaus Aehlig922fb2f2017-05-22 16:00:32 +020017 The distribution archive also contains generated files in addition to the
18 versioned sources, so this step _cannot_ be short cut by using a checkout
19 of the source tree.
Googler1fbef392017-03-22 09:05:09 +000020
Googlerc82a1612017-03-28 12:56:57 +0000213. Unzip the archive and call `bash ./compile.sh`; this will create a bazel
22 binary in `output/bazel`. This binary is self-contained, so it can be copied
23 to a directory on the PATH (such as `/usr/local/bin`) or used in-place.
Googler1fbef392017-03-22 09:05:09 +000024
Googlerc82a1612017-03-28 12:56:57 +000025## <a name="compiling-from-source-issues"></a>Known issues when compiling from source
26
27### On Windows:
Googler1fbef392017-03-22 09:05:09 +000028
29* version 0.4.4 and below: `compile.sh` may fail right after start with an error
30 like this:
31
32 ```
33 File not found - *.jar
34 no error prone jar
35 ```
36
37 Workaround is to run this (and add it to your `~/.bashrc`):
38
39 ```
40 export PATH="/bin:/usr/bin:$PATH"
41 ```
42
43* version 0.4.3 and below: `compile.sh` may fail fairly early with many Java
44 compilation errors. The errors look similar to:
45
46 ```
47 C:\...\bazel_VR1HFY7x\src\com\google\devtools\build\lib\remote\ExecuteServiceGrpc.java:11: error: package io.grpc.stub does not exist
48 import static io.grpc.stub.ServerCalls.asyncUnaryCall;
49 ^
50 ```
51
52 This is caused by a bug in one of the bootstrap scripts
Googler18a70dc2017-05-29 16:33:17 +020053 (`scripts/bootstrap/compile.sh`). Manually apply this one-line fix if you
54 want to build Bazel purely from source (without using an existing Bazel
55 binary): [5402993a5e9065984a42eca2132ec56ca3aa456f]( https://github.com/bazelbuild/bazel/commit/5402993a5e9065984a42eca2132ec56ca3aa456f).
Googler1fbef392017-03-22 09:05:09 +000056
57* version 0.3.2 and below:
58 [github issue #1919](https://github.com/bazelbuild/bazel/issues/1919)