简体   繁体   English

如何在 macOS 上安装 bazelisk?

[英]How to install a bazelisk on macOS?

I want to install Bazelisk as described here https://docs.bazel.build/versions/master/install-bazelisk.html我想按照此处所述安装 Bazelisk https://docs.bazel.build/versions/master/install-bazelisk.html

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

But how can I install that?但是我该如何安装呢? should I download the darwin file?我应该下载darwin文件吗? and then what to do?然后怎么办?

I think you can install Bazelisk using brew我认为您可以使用 brew 安装 Bazelisk

brew install bazelisk

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

This is the Github release page of theirs这是他们的 Github 发布页面

https://github.com/bazelbuild/bazelisk/releases/tag/v1.7.4 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,它会自动为你提供最新的稳定 Bazel 版本:

bazelisk version

From Official Bazel Documentation来自官方 Bazel 文档

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

Bazelisk is a wrapper for Bazel written in Go. Bazelisk 是用 Go 编写的 Bazel 包装器。 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.它会根据您当前的工作目录自动选择一个好的 Bazel 版本,从官方服务器下载它(如果需要),然后透明地通过所有命令行 arguments 传递到真正的 Bazel 二进制文件。 You can call it just like you would call Bazel.你可以像调用 Bazel 一样调用它。

Steps to Installing Bazelisk in Linux/Mac/Windows在 Linux/Mac/Windows 中安装 Bazelisk 的步骤

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以下步骤显示了 bazelisk v1.8.1 的安装,但您可以使用相同的步骤从https://github.com/bazelbuild/bazelisk/releases安装任何所需的版本

Steps for Bazelisk Linux Install Bazelisk Linux 安装步骤

> 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 Bazelisk Mac 安装步骤

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 Bazelisk Windows 安装步骤

Download and install Bazelisk windows binary from https://github.com/bazelbuild/bazelisk/releaseshttps://github.com/bazelbuild/bazelisk/releases下载并安装 Bazelisk windows 二进制文件

How to use Bazelisk and set desired Bazel version如何使用 Bazelsk 并设置所需的 Bazel 版本

  • If the environment variable USE_BAZEL_VERSION is set, it will use the version specified in the value.如果设置了环境变量USE_BAZEL_VERSION ,它将使用值中指定的版本。

  • Otherwise, if a .bazeliskrc file exists in the workspace root and contains the USE_BAZEL_VERSION variable, this version will be used.否则,如果工作空间根目录中存在.bazeliskrc文件并包含 USE_BAZEL_VERSION 变量,则将使用此版本。

  • 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.否则,如果当前目录或递归任何父目录中存在.bazelversion文件,它将读取该文件并使用其中指定的版本。

  • Otherwise it will use the official latest Bazel release.否则它将使用官方最新的 Bazel 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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