简体   繁体   中英

How to install a bazelisk on macOS?

I want to install Bazelisk as described here https://docs.bazel.build/versions/master/install-bazelisk.html

It says using a binary release for Linux, macOS, or Windows

But how can I install that? should I download the darwin file? and then what to do?

I think you can install Bazelisk using brew

brew install bazelisk

https://formulae.brew.sh/formula/bazelisk

This is the Github release page of theirs

https://github.com/bazelbuild/bazelisk/releases/tag/v1.7.4

You can install it by

curl -Lo /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-darwin-amd64

And then

chmod +x /usr/local/bin/bazelisk

Now you can just run Bazelisk and it will always automatically give you the latest stable Bazel version:

bazelisk version

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM