Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you install bazel using bazelisk

Or better yet, how do you install bazel at all. I have been using cd to get into a folder on my desktop, then I used git clone https://github.com/bazelbuild/bazelisk and then? What am I supposed to do now, honestly I didn't find any real instruction for this, I have many folder in there now, am I supposed to run a special file like bazelisk.py now? Or like build it? Was I supposed to clone the github repository in a special location? As mentioned I just choose a folder on my desktop, but I added the path to my Path enviromental variable, I added C:\Users\user\Desktop\folder\bazel and C:\Users\user\Desktop\folder\bazel\bazelisk because I wasn't sure how far I should go. So if anybody could show me how to install bazel at all I would be thankful, I just need it for a python project, I am using python 3.6.2 and I am on windows 10. I don't know what to do now because the installation steps I've read only go as far as saying to git clone the repository, but when I enter cmd and type bazel or bazel help cmd can not find the command.

like image 316
2five Avatar asked Jan 21 '26 16:01

2five


1 Answers

From Official Bazel Documentation

https://github.com/bazelbuild/bazelisk/blob/master/README.md ->

Bazelisk is a wrapper for Bazel written in Go. It automatically picks a good version of Bazel given your current working directory, downloads it from the official server (if required) and then transparently passes through all command-line arguments to the real Bazel binary. You can call it just like you would call Bazel.

Steps to Installing Bazelisk in Linux/Mac/Windows

Below steps show installation of bazelisk v1.8.1, but you can install any desired version from https://github.com/bazelbuild/bazelisk/releases using same steps

Steps for Bazelisk Linux Install

> wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-linux-amd64
> chmod +x bazelisk-linux-amd64
> sudo mv bazelisk-linux-amd64 /usr/local/bin/bazel
     
# make sure you get the binary available in $PATH
> which bazel
bazel is /usr/local/bin/bazel

Steps for Bazelisk Mac Install

wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-darwin-amd64
chmod +x bazelisk-darwin-amd64
sudo mv bazelisk-darwin-amd64 /usr/local/bin/bazel

Steps for Bazelisk Windows Install

Download and install Bazelisk windows binary from https://github.com/bazelbuild/bazelisk/releases

How to use Bazelisk and set desired Bazel version

  • If the environment variable USE_BAZEL_VERSION is set, it will use the version specified in the value.

  • Otherwise, if a .bazeliskrc file exists in the workspace root and contains the USE_BAZEL_VERSION variable, this version will be used.

  • Otherwise, if a .bazelversion file exists in the current directory or recursively any parent directory, it will read the file and use the version specified in it.

  • Otherwise it will use the official latest Bazel release.

Common issues you might face

  • When bazel version is updated in WORKSPACE file and if you are unable to see bazel version update after bazel version call

  • Then try removing old bazel binary /usr/local/bin/bazel and again do bazelisk installation mentioned above.

like image 81
rishi007bansod Avatar answered Jan 23 '26 05:01

rishi007bansod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!