Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ruff failing on my M1 Mac #42

Closed
alexeagle opened this issue Oct 31, 2023 · 5 comments · Fixed by #66
Closed

[Bug]: ruff failing on my M1 Mac #42

alexeagle opened this issue Oct 31, 2023 · 5 comments · Fixed by #66
Labels
bug Something isn't working

Comments

@alexeagle
Copy link
Member

alexeagle commented Oct 31, 2023

What happened?

bazel run tools:format fails.

Running ruff...
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 1: 4: command not found
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 2: 0: command not found
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 3: 4096: command not found
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 4: 8192: command not found
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 5: 12877824: command not found
/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/ruff_aarch64-apple-darwin/ruff: line 6: 12894208: command not found

Version

HEAD

How to reproduce

No response

Any other information?

I fetch the tool outside of Bazel:

alexeagle@MacBook-Pro-8 example % wget https://github.com/astral-sh/ruff/releases/download/v0.1.1/ruff-aarch64-apple-darwin.tar.gz
--2023-10-31 16:12:10--  https://github.com/astral-sh/ruff/releases/download/v0.1.1/ruff-aarch64-apple-darwin.tar.gz
Resolving github.com (github.com)... 192.30.255.113
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5568233 (5.3M) [application/octet-stream]
Saving to: ‘ruff-aarch64-apple-darwin.tar.gz.2’

ruff-aarch64-apple-darwin.tar.gz.2      100%[=============================================================================>]   5.31M  5.07MB/s    in 1.0s    

2023-10-31 16:12:12 (5.07 MB/s) - ‘ruff-aarch64-apple-darwin.tar.gz.2’ saved [5568233/5568233]

Then let's check the content:

alexeagle@MacBook-Pro-8 example % shasum -a 256 ruff-aarch64-apple-darwin.tar.gz
e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e  ruff-aarch64-apple-darwin.tar.gz

alexeagle@MacBook-Pro-8 example % tar -tvf ruff-aarch64-apple-darwin.tar.gz 
-rwxr-xr-x  0 runner staff 13085794 Oct 19 14:08 ruff
alexeagle@MacBook-Pro-8 example % tar -xvf !$
tar -xvf ruff-aarch64-apple-darwin.tar.gz
x ruff
alexeagle@MacBook-Pro-8 example % shasum -a 256 ruff
c7fe90b95a9e26bea01583b05f883a7b29eefe2fa628f752e5e37f7aab979785  ruff

Now we take those identical hashes and try to fetch with Bazel:

maybe(
            http_archive,
            name = "ruff_" + plat,
            url = "https://github.com/astral-sh/ruff/releases/download/v0.1.1/ruff-aarch64-apple-darwin.tar.gz",
            sha256 = "e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e",
            patch_cmds = [
                # On MacOS, `xattr -c` clears the "Unknown developer" warning when executing a fetched binary
                #"if command -v xattr > /dev/null; then xattr -c ruff; fi",
                #"chmod u+x ruff",
                "echo 'c7fe90b95a9e26bea01583b05f883a7b29eefe2fa628f752e5e37f7aab979785  ruff' | shasum -a 256 --check",
            ],
            build_file_content = """exports_files(["ruff"])""",
        )

And somehow we don't get the same checksum of the ruff binary??

% bazel fetch @ruff_aarch64-apple-darwin//:ruff                                                   
INFO: Repository ruff_aarch64-apple-darwin instantiated at:
  /Users/alexeagle/Projects/rules_lint/example/WORKSPACE.bazel:175:11: in <toplevel>
  /private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/aspect_rules_lint/lint/ruff.bzl:149:14: in fetch_ruff
  /private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
INFO: repository @ruff_aarch64-apple-darwin' used the following cache hits instead of downloading the corresponding file.
 * Hash 'e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e' for https://github.com/astral-sh/ruff/releases/download/v0.1.1/ruff-aarch64-apple-darwin.tar.gz
If the definition of 'repository @ruff_aarch64-apple-darwin' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'ruff_aarch64-apple-darwin':
   Traceback (most recent call last):
        File "/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/bazel_tools/tools/build_defs/repo/http.bzl", line 143, column 10, in _http_archive_impl
                patch(ctx, auth = auth)
        File "/private/var/tmp/_bazel_alexeagle/3eecd93732ac7c6f4f360a54a468da50/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 193, column 21, in patch
                fail("Error applying patch command %s:\n%s%s" %
Error in fail: Error applying patch command echo 'c7fe90b95a9e26bea01583b05f883a7b29eefe2fa628f752e5e37f7aab979785  ruff' | shasum -a 256 --check:
ruff: FAILED
shasum: WARNING: 1 computed checksum did NOT match
@alexeagle alexeagle added the bug Something isn't working label Oct 31, 2023
@rahul-theorem
Copy link

And somehow we don't get the same checksum of the ruff binary??

I'm also observing this (even outside rules_lint just trying to get the ruff binary pulled in). Did you wind up making any progress here?

@nlou9
Copy link
Contributor

nlou9 commented Nov 7, 2023

seeing the same issue when fetching v0.1.4/ruff-x86_64-apple-darwin.tar.gz

@xli1996
Copy link

xli1996 commented Nov 8, 2023

I have seen similar issue with bazel's download_and_extract on mac M1 and I replaced it with executing "tar" commands directly to solve the issue.

http_archive uses download_and_extract as well.

@alexeagle
Copy link
Member Author

I'm on the fence about whether we should attempt a workaround, or get the Bazel bugfix cherry-picked to the 6.4.x branch, or just instruct users to upgrade to Bazel 7.

@alexeagle
Copy link
Member Author

Here's an update on this one: bazelbuild/bazel#20269 (comment)

alexeagle added a commit that referenced this issue Dec 4, 2023
alexeagle added a commit that referenced this issue Dec 4, 2023
alexeagle added a commit that referenced this issue Dec 4, 2023
alexeagle added a commit that referenced this issue Dec 4, 2023
alexeagle added a commit that referenced this issue Dec 5, 2023
alexeagle added a commit that referenced this issue Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants