Installing Bazel on Windows


Getting Bazel

  1. Download Bazel for Windows from GitHub.

    Look for bazel-<version>-windows-x86_64.exe, for example bazel-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 to c:\bazel), so you can run Bazel by typing bazel in any directory.

  2. 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:

    1. 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).
    2. Add BAZEL_SH. Its value must be the path to MSYS2 Bash. Example: c:\msys64\usr\bin\bash.exe
    3. Add JAVA_HOME (if you will build Java code). Its value must be the directory where you installed the Java JDK 8, for example C:\Program Files\Java\jdk1.8.0_152. In order to use this with the default local_jdk javabase, it must be installed on a volume which Windows considers to be local, network mounted filesystems will not work.

    None of these paths should contain spaces or non-ASCII characters.

Other ways to get Bazel

Install using Chocolatey

  1. Install the Chocolatey package manager

  2. 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.

Install using Scoop

  1. Install the Scoop package manager using the following PowerShell command:

    iex (new-object net.webclient).downloadstring('')
  2. Install the Bazel package:

    scoop install bazel

See Scoop installation and package maintenance guide for more information about the Scoop package.

Using Bazel

Once you have installed Bazel, see Using Bazel on Windows.