Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 1 | --- |
| 2 | layout: documentation |
| 3 | title: Compile Bazel from Source |
| 4 | --- |
| 5 | |
| 6 | # <a name="compiling-from-source"></a>Compile Bazel from source |
| 7 | |
aehlig | 052c2dc | 2017-03-29 14:10:25 +0000 | [diff] [blame] | 8 | 1. Ensure that you have OpenJDK 8 installed on your system. |
Googler | 18a70dc | 2017-05-29 16:33:17 +0200 | [diff] [blame] | 9 | For a system based on debian packages (e.g. Debian, Ubuntu), install |
aehlig | 052c2dc | 2017-03-29 14:10:25 +0000 | [diff] [blame] | 10 | OpenJDK 8 by running the command `sudo apt-get install openjdk-8-jdk`. |
Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 11 | |
Googler | c82a161 | 2017-03-28 12:56:57 +0000 | [diff] [blame] | 12 | 2. 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 Aehlig | 922fb2f | 2017-05-22 16:00:32 +0200 | [diff] [blame] | 17 | 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. |
Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 20 | |
Googler | c82a161 | 2017-03-28 12:56:57 +0000 | [diff] [blame] | 21 | 3. 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. |
Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 24 | |
Googler | c82a161 | 2017-03-28 12:56:57 +0000 | [diff] [blame] | 25 | ## <a name="compiling-from-source-issues"></a>Known issues when compiling from source |
| 26 | |
| 27 | ### On Windows: |
Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 28 | |
| 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 |
Googler | 18a70dc | 2017-05-29 16:33:17 +0200 | [diff] [blame] | 53 | (`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). |
Googler | 1fbef39 | 2017-03-22 09:05:09 +0000 | [diff] [blame] | 56 | |
| 57 | * version 0.3.2 and below: |
| 58 | [github issue #1919](https://github.com/bazelbuild/bazel/issues/1919) |