Installing Bazel on Windows
Prerequisites
-
64 bit Windows 7 or newer, or 64 bit Windows Server 2008 R2 or newer
-
Microsoft Visual C++ Redistributable for Visual Studio 2015
These are common DLLs that Bazel needs. You may already have them installed.
Getting Bazel
-
Download Bazel for Windows from GitHub.
Look for
bazel-<version>-windows-x86_64.exe
, for examplebazel-0.16.1-windows-x86_64.exe
.Tip: Rename the binary to
bazel.exe
and move it to a directory on your%PATH%
(for example toc:\bazel
), so you can run Bazel by typingbazel
in any directory. -
Edit environment variables.
Open the “Environment Variables” dialog box from Control Panel or Start Menu, and add or edit the following variables under the “User variables” section:
- Edit
Path
. Add new entries to the beginning of the list:- The directory of
bazel.exe
. (Example:c:\bazel
). - The
usr\bin
directory of MSYS2. (Example:c:\msys64\usr\bin
). - If you will build Python code: the directory of
python.exe
. (Example:c:\python3
).
- The directory of
- Add
BAZEL_SH
. Its value must be the path to MSYS2 Bash. Example:c:\msys64\usr\bin\bash.exe
- Add
JAVA_HOME
(if you will build Java code). Its value must be the directory where you installed the Java JDK 8, for exampleC:\Program Files\Java\jdk1.8.0_152
None of these paths should contain spaces or non-ASCII characters.
- Edit
Other ways to get Bazel
Install using Chocolatey
-
Install the Chocolatey package manager
-
Install the Bazel package:
choco install bazel
This command will install the latest available version of Bazel and its dependencies, such as the MSYS2 shell. This will not install Visual C++ though.
See Chocolatey installation and package maintenance guide for more information about the Chocolatey package.
Using Bazel
Once you have installed Bazel, see Using Bazel on Windows.