Kristina Chodorow | 974b208 | 2015-03-31 14:49:30 +0000 | [diff] [blame] | 1 | --- |
dzc | 22b85a2 | 2017-05-31 20:37:50 +0200 | [diff] [blame] | 2 | layout: documentation |
| 3 | title: Installing Bazel |
Kristina Chodorow | 974b208 | 2015-03-31 14:49:30 +0000 | [diff] [blame] | 4 | --- |
dzc | 22b85a2 | 2017-05-31 20:37:50 +0200 | [diff] [blame] | 5 | |
| 6 | # Installing Bazel |
| 7 | |
| 8 | See the instructions for installing Bazel on: |
| 9 | |
| 10 | * [Ubuntu Linux (16.04, 15.10, and 14.04)](install-ubuntu.md) |
Jakob Buchgraber | 63a6e91 | 2017-09-25 19:06:19 +0200 | [diff] [blame] | 11 | * [Fedora 25, 26, and CentOS 7](install-redhat.md) |
dzc | 22b85a2 | 2017-05-31 20:37:50 +0200 | [diff] [blame] | 12 | * [Mac OS X](install-os-x.md) |
Googler | 1a72fb7 | 2017-09-12 14:18:30 +0200 | [diff] [blame] | 13 | * [Windows](install-windows.md) |
dzc | 22b85a2 | 2017-05-31 20:37:50 +0200 | [diff] [blame] | 14 | |
| 15 | For other platforms, you can try to [compile from source](install-compile-source.md). |
| 16 | |
| 17 | Required Java version: |
| 18 | |
| 19 | Java JDK 8 or later is required. To address the problem of JDK 8 not being |
| 20 | available on some machines, Bazel's binary installer embeds a JDK by default. |
| 21 | |
| 22 | **Note:** Homebrew and Debian packages do not contain the embedded JDK. The |
| 23 | shell installers are the only ones with an embedded JDK. |
| 24 | |
| 25 | Extras: |
| 26 | |
| 27 | * [Bash completion](#bash) |
| 28 | * [zsh completion](#zsh) |
| 29 | |
| 30 | For more information on using Bazel, see |
| 31 | [Getting Started with Bazel](getting-started.html). |
| 32 | |
dzc | 22b85a2 | 2017-05-31 20:37:50 +0200 | [diff] [blame] | 33 | ## <a name="bash"></a>Getting bash completion |
| 34 | |
| 35 | Bazel comes with a bash completion script, which the installer copies into the |
| 36 | `bin` directory. If you ran the installer with `--user`, this will be |
| 37 | `$HOME/.bazel/bin`. If you ran the installer as root, this will be |
| 38 | `/usr/local/bazel/bin`. |
| 39 | |
| 40 | Copy the `bazel-complete.bash` script to your completion folder |
| 41 | (`/etc/bash_completion.d` directory under Ubuntu). If you don't have a |
| 42 | completion folder, you can copy it wherever suits you and insert |
| 43 | `source /path/to/bazel-complete.bash` in your `~/.bashrc` file (under OS X, put |
| 44 | it in your `~/.bash_profile` file). |
| 45 | |
| 46 | If you built Bazel from source, the bash completion target is in the `//scripts` |
| 47 | package: |
| 48 | |
| 49 | 1. Build it with Bazel: `bazel build //scripts:bazel-complete.bash`. |
| 50 | 2. Copy the script `bazel-bin/scripts/bazel-complete.bash` to one of the |
| 51 | locations described above. |
| 52 | |
| 53 | ## <a name="zsh"></a>Getting zsh completion |
| 54 | |
| 55 | Bazel also comes with a zsh completion script. To install it: |
| 56 | |
| 57 | 1. Add this script to a directory on your $fpath: |
| 58 | |
| 59 | ``` |
| 60 | fpath[1,0]=~/.zsh/completion/ |
| 61 | mkdir -p ~/.zsh/completion/ |
| 62 | cp scripts/zsh_completion/_bazel ~/.zsh/completion |
| 63 | ``` |
| 64 | |
| 65 | You may have to call `rm -f ~/.zcompdump; compinit` |
| 66 | the first time to make it work. |
| 67 | |
| 68 | 2. Optionally, add the following to your .zshrc. |
| 69 | |
| 70 | ``` |
| 71 | # This way the completion script does not have to parse Bazel's options |
| 72 | # repeatedly. The directory in cache-path must be created manually. |
| 73 | zstyle ':completion:*' use-cache on |
| 74 | zstyle ':completion:*' cache-path ~/.zsh/cache |
| 75 | ``` |