Installing Bazel on Windows (original) (raw)

Report an issue View source Nightly 8.1·8.0·7.5·7.4·7.3·7.2

This page describes the requirements and steps to install Bazel on Windows. It also includes troubleshooting and other ways to install Bazel, such as using Chocolatey or Scoop.

Installing Bazel

This section covers the prerequisites, environment setup, and detailed steps during installation on Windows.

Check your system

Recommended: 64 bit Windows 10, version 1703 (Creators Update) or newer

To check your Windows version:

Install the prerequisites

Download Bazel

Recommended: Use Bazelisk

Alternatively you can:

Set up your environment

To make Bazel easily accessible from command prompts or PowerShell by default, you can rename the Bazel binary to bazel.exe and add it to your default paths.

set PATH=%PATH%;path to the Bazel binary

You can also change your system PATH environment variable to make it permanent. Check out how to set environment variables.

Done

"Success: You've installed Bazel."

To check the installation is correct, try to run:

bazel version

Next, you can check out more tips and guidance here:

Installing compilers and language runtimes

Depending on which languages you want to build, you will need:

pacman -S zip unzip patch diffutils git  

Optional: If you want to use Bazel from CMD or Powershell and still be able to use Bash tools, make sure to addMSYS2_INSTALL_PATH/usr/bin to yourPATH environment variable.

Troubleshooting

Bazel does not find Bash or bash.exe

Possible reasons:

Solution:

Ensure you installed MSYS2 x86_64.

If that doesn't help:

  1. Go to Start Menu > Settings.
  2. Find the setting "Edit environment variables for your account"
  3. Look at the list on the top ("User variables for "), and click the "New..." button below it.
  4. For "Variable name", enter BAZEL_SH
  5. Click "Browse File..."
  6. Navigate to the MSYS2 directory, then to usr\bin below it.
    For example, this might be C:\msys64\usr\bin on your system.
  7. Select the bash.exe or bash file and click OK
  8. The "Variable value" field now has the path to bash.exe. Click OK to close the window.
  9. Done.
    If you open a new cmd.exe or PowerShell terminal and run Bazel now, it will find Bash.

Bazel does not find Visual Studio or Visual C++

Possible reasons:

Solution:

  1. Go to Start Menu > Settings.
  2. Find the setting "Edit environment variables for your account"
  3. Look at the list on the top ("User variables for "), and click the "New..." button below it.
  4. For "Variable name", enter BAZEL_VC
  5. Click "Browse Directory..."
  6. Navigate to the VC directory of Visual Studio.
    For example, this might be C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VCon your system.
  7. Select the VC folder and click OK
  8. The "Variable value" field now has the path to VC. Click OK to close the window.
  9. Done.
    If you open a new cmd.exe or PowerShell terminal and run Bazel now, it will find Visual C++.

Other ways to install Bazel

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.

Using Scoop

  1. Install the Scoop package manager using the following PowerShell command:
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')  
  1. Install the Bazel package:
scoop install bazel  

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

Build from source

To build Bazel from scratch instead of installing, see Compiling from source.