Search code examples
gitgithubbazelchecksumsha

Bazel test returns checksum mismatch error for private GitHub repos


I am trying to run some tests present on a GitHub repo. The repo depends on some other private repo available on my company's GitHub. They haven't really provided me with a Readme to run the tests, but I have a Makefile in the project that I am using. This is the Bazel command they are using for building the tests:

bazel \
--host_jvm_args=-Djavax.net.ssl.trustStore='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/cacerts' \
--host_jvm_args=-Djavax.net.ssl.trustStorePassword='changeit' \
test --features=race //test/e2e/...

NOTE: I had to add --host_jvm_args arguments because otherwise the command was failing with a SunCertPathBuilderException: unable to find valid certification path to requested target error.

But, on running the above command, I get this error:

ERROR: An error occurred during the fetch of repository 'com_github_pie_<company>_<repo-name>_bazel_prettier':
   java.io.IOException: Error downloading [https://github.pie.<company>.com/<repo-name>/bazel-prettier/archive/v0.0.2.tar.gz] to /private/var/tmp/_bazel_<my-user-name>/492c2b2abdc487331e7cccd373c45b9c/external/com_github_pie_<company>_<repo-name>_prettier/v0.0.2.tar.gz: Checksum was 9148ae6fb489b66238cf3b003ae22b107e00ab2583856ee81659967f2245ba46 but wanted 9d64c8d1301b78ddf87ac2774fccbe28006448d000838cb92441cc7997455426

I am unable to find a possible cause of this error online. Can someone guide me to what could be the cause and a possible solution to fix this error?


Solution

  • Read the error message carefully:

    Checksum was 9148ae6fb489b66238cf3b003ae22b107e00ab2583856ee81659967f2245ba46 but wanted 9d64c8d1301b78ddf87ac2774fccbe28006448d000838cb92441cc7997455426
    

    There is something like this in the WORKSPACE or WORKSPACE.bazel file - or something that is "included" by those files:

    http_archive(
        name = "com_grail_bazel_toolchain",
        sha256 = "9d64c8d1301b78ddf87ac2774fccbe28006448d000838cb92441cc7997455426",
        strip_prefix = "bazel-toolchain-master",
        urls = ["https://github.com/grailbio/bazel-toolchain/archive/master.tar.gz"],
    )
    

    Just change the sha256 checksum to that one Bazel suggest or remove it.