bazelisk icon indicating copy to clipboard operation
bazelisk copied to clipboard

bazelisk from homebrew looks for macOS arm binary 4.0.0 and 404s

Open loyaltyarm opened this issue 3 years ago • 17 comments

when attempting to build a project with .bazelversion defined as 4.0.0 (bazel-buildfarm) on macOS, the following is broken in bazelisk:

cobbler-laptop01:bazel-buildfarm loyaltyarm$ bazel --version
2021/06/10 01:08:45 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64...
2021/06/10 01:08:45 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404

Manually checking the releases hosting at github shows no arm64 binary available for 4.0.0. Can we fix the reference to the appropriate version for arm64 on macOS?

loyaltyarm avatar Jun 10 '21 08:06 loyaltyarm

Also 404s on version 3.7.2

2021/06/29 14:40:56 Downloading https://releases.bazel.build/3.7.2/release/bazel-3.7.2-darwin-arm64...
2021/06/29 14:40:56 could not download Bazel: HTTP GET https://releases.bazel.build/3.7.2/release/bazel-3.7.2-darwin-arm64 failed with error 404

bramses avatar Jun 29 '21 18:06 bramses

The issue seems to be fixed in 4.2.1 at https://releases.bazel.build/4.2.1/release/bazel-4.2.1-darwin-arm64.

mhmyesman avatar Sep 10 '21 14:09 mhmyesman

The issue seems to be fixed in 4.2.1 at https://releases.bazel.build/4.2.1/release/bazel-4.2.1-darwin-arm64.

Still not fixed in official releases I'm afraid.

mhmyesman avatar Oct 09 '21 03:10 mhmyesman

@mhmyesman Could you explain what you mean with "Still not fixed in official releases"?

It seems to work for me with Bazelisk 1.10.1 installed from Homebrew on my MacBook Pro M1:

$ which bazel
/opt/homebrew/bin/bazel
$ ls -ld $(which bazel)
lrwxr-xr-x  1 philwo  admin  35 Jul 29 11:29 /opt/homebrew/bin/bazel -> ../Cellar/bazelisk/1.10.1/bin/bazel
$ brew info bazelisk
bazelisk: stable 1.10.1 (bottled), HEAD
$ uname -sm
Darwin arm64
$ bazel --version
2021/10/11 17:18:38 Downloading https://releases.bazel.build/4.2.1/release/bazel-4.2.1-darwin-arm64...
bazel 4.2.1

philwo avatar Oct 11 '21 15:10 philwo

IIUC this is a feature request that for Bazel versions before 4.1.0 (the first version that had Darwin arm64 binaries) you'd like Bazelisk to download the x86_64 version even on arm64 macOS instead of failing, right?

I think we can do this, yes.

philwo avatar Oct 11 '21 15:10 philwo

any update?

sfyumi avatar Nov 24 '21 07:11 sfyumi

Seeing the same issue. An update would be great.

ajonnavi avatar Nov 26 '21 23:11 ajonnavi

@avadhanij6si Are you using the latest version of bazel? This issue is fixed in this version (4.2.1)

Ruthreshwar avatar Nov 28 '21 13:11 Ruthreshwar

@Ruthreshwar, Yes I am using the latest version of bazelisk.

$ bazelisk --version
bazel 4.2.1

When I cd into the repo which contains a .bazelversion file, I get the following

$ bazelisk --version
2021/11/29 16:30:05 Downloading https://releases.bazel.build/3.3.0/release/bazel-3.3.0-darwin-arm64...
2021/11/29 16:30:05 could not download Bazel: HTTP GET https://releases.bazel.build/3.3.0/release/bazel-3.3.0-darwin-arm64 failed with error 404

ajonnavi avatar Nov 30 '21 00:11 ajonnavi

@avadhanij6si Check the version number in .bazelverion file. I suspect there should be an issue with the .bazelversion file. If everything is correct remove the .bazelversion and give a try.

Ruthreshwar avatar Nov 30 '21 10:11 Ruthreshwar

@Ruthreshwar, the .bazelversion works fine on regular Macs. It literally has only one line that says - 3.3.0.

Removing it kind of defeats the purpose of having it in the first place, don't you think? It's part of the repo, and something folks don't have to know or mess around with, and they always get the right version.

The behavior implies it's a bug. Perhaps the value of arch could be used? It would mean that folks have to use x86_64 based terminal app.

ajonnavi avatar Dec 06 '21 00:12 ajonnavi

@avadhanij6si The issue was fixed as part of 4.2.1 release. So if you are using the older version in .bazelversion it won't work. New macs are with new chip set and architecture so old version you are using might work in other macs but not in new mac. Also if you look at the thread it is mentioned that this is a feature request for older Bazel versions.

Ruthreshwar avatar Dec 06 '21 00:12 Ruthreshwar

I understand that, and I am not expecting an arm64 version for 3.3.0. I think it would be cleaner if Bazelisk could fetch the x86_64 version for older versions where arm binaries don't exist.

Also if you look at the thread it is mentioned that this is a feature request for older Bazel versions.

But @philwo remarked on it, and I am basically asking for the same behavior.

IIUC this is a feature request that for Bazel versions before 4.1.0 (the first version that had Darwin arm64 binaries) you'd like Bazelisk to download the x86_64 version even on arm64 macOS instead of failing, right?

I think we can do this, yes.

ajonnavi avatar Dec 06 '21 02:12 ajonnavi

I am also facing this issue. Not suitable for Mac.

ajithu@Ajiths-MacBook-Pro repo % bazel --version
2021/12/09 16:20:27 Downloading https://releases.bazel.build/3.7.1/release/bazel-3.7.1-darwin-arm64...
2021/12/09 16:20:27 could not download Bazel: HTTP GET https://releases.bazel.build/3.7.1/release/bazel-3.7.1-darwin-arm64 failed with error 404
ajithu@Ajiths-MacBook-Pro repo %

Same issues with other versions like 4.0.0 and 3.7.8

uajith avatar Dec 21 '21 11:12 uajith

Yeah. I'm really struggling to get Bazel to work because I need 3.x and it keeps fetching the arm64 file instead of the x86_64 file.

philipturner avatar Jan 02 '22 22:01 philipturner

I'm having an identical issue. The problem is that removing the version number in .bazelversion produces problems as well.

Not removing the .bazelversion: gerrit-internal % bazelisk build release 2022/02/01 18:32:43 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64... 2022/02/01 18:32:43 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404 gerrit-internal % bazel --version 2022/02/01 18:32:47 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64... 2022/02/01 18:32:47 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404 gerrit-internal % cd .. Documents % bazel --version bazel 5.0.0

Removing the bazelversion: WARNING: Option 'java_toolchain' is deprecated INFO: Invocation ID: 9d2bce6d-671c-481d-8fd0-581a7cca5035 DEBUG: /private/var/tmp/_bazel_I561397/4e32bb3b320953c652b19891e7724eee/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:68:14: Current running Bazel is ahead of bazel-toolchains repo. Please update your pin to bazel-toolchains repo in your WORKSPACE file. DEBUG: /private/var/tmp/_bazel_I561397/4e32bb3b320953c652b19891e7724eee/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:125:14: rbe_default not using checked in configs; Bazel version 5.0.0 was picked/selected but no checked in config was found in map {"0.20.0": ["8.0.0"], "0.21.0": ["8.0.0"], "0.22.0": ["8.0.0", "9.0.0"], "0.23.0": ["8.0.0", "9.0.0"], "0.23.1": ["8.0.0", "9.0.0"], "0.23.2": ["9.0.0"], "0.24.0": ["9.0.0"], "0.24.1": ["9.0.0"], "0.25.0": ["9.0.0"], "0.25.1": ["9.0.0"], "0.25.2": ["9.0.0"], "0.26.0": ["9.0.0"], "0.26.1": ["9.0.0"], "0.27.0": ["9.0.0"], "0.27.1": ["9.0.0"], "0.28.0": ["9.0.0"], "0.28.1": ["9.0.0"], "0.29.0": ["9.0.0"], "0.29.1": ["9.0.0", "10.0.0"], "1.0.0": ["9.0.0", "10.0.0"], "1.0.1": ["10.0.0"], "1.1.0": ["10.0.0"], "1.2.0": ["10.0.0"], "1.2.1": ["10.0.0"], "2.0.0": ["10.0.0"], "2.1.0": ["10.0.0"], "2.1.1": ["10.0.0", "11.0.0"], "2.2.0": ["11.0.0"], "3.0.0": ["11.0.0"], "3.1.0": ["11.0.0"], "3.2.0": ["11.0.0"], "3.3.0": ["11.0.0"], "3.3.1": ["11.0.0"], "3.4.1": ["11.0.0"], "3.5.0": ["11.0.0"], "3.5.1": ["11.0.0"], "3.6.0": ["11.0.0"], "3.7.0": ["11.0.0"], "3.7.1": ["11.0.0"], "3.7.2": ["11.0.0"], "4.0.0": ["11.0.0"]} ERROR: /Users/-/Documents/gerrit-internal/plugins/gitiles/BUILD:4:14: //plugins/gitiles:gitiles__plugin: no such attribute 'resource_jars' in 'java_library' rule ERROR: /Users/-/Documents/gerrit-internal/plugins/reviewers/BUILD:14:14: //plugins/reviewers:reviewers__plugin: no such attribute 'resource_jars' in 'java_library' rule ERROR: /Users/-/Documents/gerrit-internal/plugins/codemirror-editor/BUILD:5:14: //plugins/codemirror-editor:codemirror-editor__plugin: no such attribute 'resource_jars' in 'java_library' rule ERROR: /Users/-/Documents/gerrit-internal/plugins/delete-project/BUILD:14:14: //plugins/delete-project:delete-project__plugin: no such attribute 'resource_jars' in 'java_library' rule ERROR: /Users/-/Documents/gerrit-internal/plugins/serviceuser/BUILD:8:14: //plugins/serviceuser:serviceuser__plugin: no such attribute 'resource_jars' in 'java_library' rule ERROR: /Users/-/Documents/gerrit-internal/plugins/BUILD:10:9: Target '//plugins/codemirror-editor:codemirror-editor.jar' contains an error and its package is in error and referenced by '//plugins:core' ERROR: /Users/-/Documents/gerrit-internal/plugins/BUILD:10:9: Target '//plugins/delete-project:delete-project.jar' contains an error and its package is in error and referenced by '//plugins:core' ERROR: /Users/-/Documents/gerrit-internal/plugins/BUILD:10:9: Target '//plugins/gitiles:gitiles.jar' contains an error and its package is in error and referenced by '//plugins:core' ERROR: /Users/-/Documents/gerrit-internal/plugins/BUILD:10:9: Target '//plugins/reviewers:reviewers.jar' contains an error and its package is in error and referenced by '//plugins:core' ERROR: /Users/-/Documents/gerrit-internal/plugins/BUILD:10:9: Target '//plugins/serviceuser:serviceuser.jar' contains an error and its package is in error and referenced by '//plugins:core' ERROR: Analysis of target '//:release' failed; build aborted: INFO: Elapsed time: 0.180s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

Oops, looks like I need 4.0.0 after all.

My next step is removing /opt/homebrew/bin/bazel and manually installing bazel 4.0.0 with the instructions found in the bazel docs. Now I have 4.0.0, which is what the .bazelversion wants, so all should be well... right?

bazelisk build release
2022/02/02 09:04:26 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64... 2022/02/02 09:04:26 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404 gerrit-internal % bazel --version bazel 4.0.0

Running 'bazel build release' works, but of course, then I'm not using bazelisk...

aMiss-aWry avatar Feb 02 '22 08:02 aMiss-aWry

@aMiss-aWry There is no arm64 version of Bazel 4.0.0 for macOS, which is why that one fails to download. Bazel 5.0.0 is a major release that contains incompatible changes, so it's probably not yet compatible with the project you're trying to build.

You could try with either Bazel 4.2.2 (preferably) or 4.1.0 - both of these versions are backwards compatible with Bazel 4.0 and already support arm64 on macOS. Either by overriding the .bazelversion file in your project: echo 4.2.2 > .bazelversion or by setting an environment variable (which will have precedence over the .bazelversion file): export USE_BAZEL_VERSION=4.2.2. Details in the docs: https://github.com/bazelbuild/bazelisk#how-does-bazelisk-know-which-bazel-version-to-run

Going forward, we can also add a version switch in Bazelisk like proposed in https://github.com/bazelbuild/bazelisk/pull/272 which will let Bazelisk download the x86_64 version of Bazel on macOS if an arm64 version is not yet available.

philwo avatar Feb 02 '22 08:02 philwo