blob: 3fe9ee3c04616ebcea0c21c3133da8a7b88d6870 [file] [log] [blame] [view]
Googler1fbef392017-03-22 09:05:09 +00001--------------------------------------------------------------------------------
2
3layout: documentation
4
5## title: Installing Bazel on Ubuntu
6
7# <a name="ubuntu"></a>Install Bazel on Ubuntu
8
9Supported Ubuntu Linux platforms:
10
11* 16.04 (LTS)
12* 15.10
13
14Install Bazel on Ubuntu using one of the following methods:
15
16* [Use our custom APT repository (recommended)](#install-on-ubuntu)
17* [Use the binary installer](#install-with-installer-ubuntu)
18* [Compile Bazel from source](#install-compile-source.md)
19
20Bazel comes with two completion scripts. After installing Bazel, you can:
21
22* access the [bash completion script](install.md)
23* install the [zsh completion script](install.md)
24
25## <a name="install-on-ubuntu"></a> Using Bazel custom APT repository (recommended)
26
27### 1. Add Bazel distribution URI as a package source (one time setup)
28
29```
30$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
31$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
32```
33
34If you want to use the JDK 7, please replace `jdk1.8` with `jdk1.7` and if you
35want to install the testing version of Bazel, replace `stable` with `testing`.
36
37### 2. Install and update Bazel
38
39`$ sudo apt-get update && sudo apt-get install bazel`
40
41Once installed, you can upgrade to newer version of Bazel with:
42
43`$ sudo apt-get upgrade bazel`
44
45## <a name="install-with-installer-ubuntu"></a>Install with installer
46
47We provide binary installers on our
48<a href="https://github.com/bazelbuild/bazel/releases">GitHub releases page</a>
49
50The installer only contains Bazel binary, some additional libraries are required
51to be installed on the machine to work.
52
53### 1. Install JDK 8
54
55To install OpenJDK 8:
56
57```
58$ sudo apt-get install openjdk-8-jdk
59```
60
61### 2. Install other required packages
62
63```
64$ sudo apt-get install pkg-config zip g++ zlib1g-dev unzip
65```
66
67### 3. Download Bazel
68
69Download the [Bazel installer](https://github.com/bazelbuild/bazel/releases) for
70your operating system.
71
72### 4. Run the installer
73
74Run the installer:
75
76<pre>
77$ chmod +x bazel-<em>version</em>-installer-<em>os</em>.sh
78$ ./bazel-<em>version</em>-installer-<em>os</em>.sh --user
79</pre>
80
81The `--user` flag installs Bazel to the `$HOME/bin` directory on your system and
82sets the `.bazelrc` path to `$HOME/.bazelrc`. Use the `--help` command to see
83additional installation options.
84
85### 5. Set up your environment
86
87If you ran the Bazel installer with the `--user` flag as above, the Bazel
88executable is installed in your `$HOME/bin` directory. It's a good idea to add
89this directory to your default paths, as follows:
90
91```bash
92$ export PATH="$PATH:$HOME/bin"
93```
94
95You can also add this command to your `~/.bashrc` file.