Supported platforms:
For other platforms, you can try to compile from source.
Required Java version:
Extras:
For more information on using Bazel, see Getting started.
Install Bazel on Ubuntu using one of the following methods:
If you are running Ubuntu Wily (15.10), you can skip this step. But for Ubuntu Trusty (14.04 LTS) users, since OpenJDK 8 is not available on Trusty, please install Oracle JDK 8:
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
Note: You might need to sudo apt-get install software-properties-common
if you don't have the add-apt-repository
command. See here.
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list $ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
If you want to use the JDK 7, please replace jdk1.8
with jdk1.7
and if you want to install the testing version of Bazel, replace stable
with testing
.
$ sudo apt-get update && sudo apt-get install bazel
Once installed, you can upgrade to newer version of Bazel with:
$ sudo apt-get upgrade bazel
We provide binary installers on our GitHub releases page
The installer only contains Bazel binary, some additional libraries are required to be installed on the machine to work.
Ubuntu Trusty (14.04 LTS). OpenJDK 8 is not available on Trusty. To install Oracle JDK 8:
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
Note: You might need to sudo apt-get install software-properties-common
if you don't have the add-apt-repository
command. See here.
Ubuntu Wily (15.10). To install OpenJDK 8:
$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get install pkg-config zip g++ zlib1g-dev unzip
Download the Bazel installer for your operating system.
Run the installer:
The --user
flag installs Bazel to the $HOME/bin
directory on your system and sets the .bazelrc
path to $HOME/.bazelrc
. Use the --help
command to see additional installation options.
If you ran the Bazel installer with the --user
flag as above, the Bazel executable is installed in your $HOME/bin
directory. It's a good idea to add this directory to your default paths, as follows:
$ export PATH="$PATH:$HOME/bin"
You can also add this command to your ~/.bashrc
file.
Install Bazel on Mac OS X using one of the following methods:
JDK 8 can be downloaded from Oracle's JDK Page. Look for “Mac OS X x64” under “Java SE Development Kit”. This will download a DMG image with an install wizard.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install bazel
You are all set. You can confirm Bazel is installed successfully by running bazel version
.
You can later upgrade to newer version of Bazel with brew upgrade bazel
.
We provide binary installers on our GitHub releases page
The installer only contains Bazel binary, some additional libraries are required to be installed on the machine to work.
JDK 8 can be downloaded from Oracle's JDK Page. Look for “Mac OS X x64” under “Java SE Development Kit”. This will download a DMG image with an install wizard.
Xcode can be downloaded from the Apple Developer Site, which will redirect to the App Store.
For objc_*
and ios_*
rule support, you must have Xcode 6.1 or later with iOS SDK 8.1 installed on your system.
Once XCode is installed you can trigger signing the license with the following command:
$ sudo gcc --version
Download the Bazel installer for your operating system.
Run the installer:
The --user
flag installs Bazel to the $HOME/bin
directory on your system and sets the .bazelrc
path to $HOME/.bazelrc
. Use the --help
command to see additional installation options.
If you ran the Bazel installer with the --user
flag as above, the Bazel executable is installed in your $HOME/bin
directory. It's a good idea to add this directory to your default paths, as follows:
$ export PATH="$PATH:$HOME/bin"
You can also add this command to your ~/.bashrc
file.
You are all set. You can confirm Bazel is installed successfully by running bazel version
.
Windows support is highly experimental. Known issues are marked with label “Windows” on GitHub issues.
We currently support only 64 bit Windows 7 or higher and we compile Bazel as a MSYS2 binary.
Install Bazel on Windows using one of the following methods:
You can install the unofficial package using the chocolatey package manager:
choco install bazel
This will install the latest available version of bazel, and dependencies.
This package is experimental; please provide feedback to @petemounce
in GitHub issue tracker. See the Chocolatey installation and package maintenance guide for more information.
We provide binary versions on our GitHub releases page
This is merely the Bazel binary. You'll need additional software (e.g. msys2 shell of the right version) and some setup in your environment to run Bazel. See these requirements on our Windows page.
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 (for releases 0.4.0 and earlier: download the “source code” zip archive and note that it will only work for the supported architectures as it contains binaries). We recommend to also verify the signature made by our release key 48457EE0.
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 (e.g., /usr/local/bin
) or used in-place.
###Known issues when compiling from source
On Windows:
version 0.4.4 and below: compile.sh
may fail right after start with an error like this:
File not found - *.jar no error prone jar
Workaround is to run this (and add it to your ~/.bashrc
):
export PATH="/bin:/usr/bin:$PATH"
version 0.4.3 and below: compile.sh
may fail fairly early with many Java compilation errors. The errors look similar to:
C:\...\bazel_VR1HFY7x\src\com\google\devtools\build\lib\remote\ExecuteServiceGrpc.java:11: error: package io.grpc.stub does not exist import static io.grpc.stub.ServerCalls.asyncUnaryCall; ^
This is caused by a bug in one of the bootstrap scripts (scripts/bootstrap/compile.sh
). Manually apply this one-line fix if you want to build Bazel purely from source (without using an existing Bazel binary): 5402993a5e9065984a42eca2132ec56ca3aa456f.
version 0.3.2 and below: github issue #1919
Bazel version 0.1.0 runs without any change with JDK 7. However, future version will stop supporting JDK 7 when our CI cannot build for it anymore. The installer for JDK 7 for Bazel versions after 0.1.0 is labeled
If you wish to use JDK 7, follow the same steps as for JDK 8 but with the jdk7 installer or using a different APT repository as described here.
Bazel comes with a bash completion script, which the installer copies into the bin
directory. If you ran the installer with --user
, this will be $HOME/.bazel/bin
. If you ran the installer as root, this will be /usr/local/bazel/bin
.
Copy the bazel-complete.bash
script to your completion folder (/etc/bash_completion.d
directory under Ubuntu). If you don't have a completion folder, you can copy it wherever suits you and insert source /path/to/bazel-complete.bash
in your ~/.bashrc
file (under OS X, put it in your ~/.bash_profile
file).
If you built Bazel from source, the bash completion target is in the //scripts
package:
bazel build //scripts:bazel-complete.bash
.bazel-bin/scripts/bazel-complete.bash
to one of the locations described above.Bazel also comes with a zsh completion script. To install it:
Add this script to a directory on your $fpath:
fpath[1,0]=~/.zsh/completion/ mkdir -p ~/.zsh/completion/ cp scripts/zsh_completion/_bazel ~/.zsh/completion
You may have to call rm -f ~/.zcompdump; compinit
the first time to make it work.
Optionally, add the following to your .zshrc.
# This way the completion script does not have to parse Bazel's options # repeatedly. The directory in cache-path must be created manually. zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh/cache