使用 Bazelisk 安装特定版本的 Bazel

Install specific version of Bazel with Bazelisk

我正在尝试使用 Bazel 通过编译器标志重建 Tensorflow,但一直出现错误。

documentation explaining how to build Tensorflow from the source, they say that Bazelisk will download the correct version for Tensorflow... but when I was getting the errors, I decided to check the Bazel version and it said 4.2.2 (which is the latest version). The tested builds 中,对于 2.7 版本的 Tensorflow(这是我正在使用的),Bazel 版本仅为 3.7.2...

有没有办法使用Bazelisk安装3.7.2版本?还是我必须手动下载 Bazel 并将其添加到路径中?

Bazelisk 将在 WORKSPACE 根目录中查找名为 .bazelversion 的文件(参见 here)。该文件应该包含您要使用的 Bazel 版本号。

还有其他选项可以告诉 Bazelisk 使用哪个版本:How does Bazelisk know which Bazel version to run?

例如,要使用 Bazel 0.26.1,您可以通过以下方式使用 Bazelisk:

$ USE_BAZEL_VERSION=0.26.1 bazelisk version