Cannot fetch Eigen with bazel: 406 Not Acceptable
Asked Answered
B

2

7

When trying to download Eigen with

http_archive(
    name = "eigen",
    strip_prefix = "eigen-3.3.7",
    sha256 = "d56fbad95abf993f8af608484729e3d87ef611dd85b3380a8bad1d5cbc373a57",
    urls = [
        "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz"
    ],
    build_file = "//third_party:eigen.BUILD"
)

bazel fetch yields the error

WARNING: Download from https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 406 Not Acceptable
ERROR: An error occurred during the fetch of repository 'eigen':
   java.io.IOException: Error downloading [https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz]

I has been working for weeks so I am wondering if the problem comes from bazel or from the GitLab server?

Becalmed answered 26/3, 2020 at 9:53 Comment(4)
Does wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz work?Hist
I have the same problem - wget works - http_archive gives me the same error (Bazel 2.2.0)Amylopectin
I confirm that wget works, but not bazel fetchBecalmed
Reproducible with github.com/fenollp/gitlab_bazel_406_on_download_and_extract It's probably some HTTP header that either Bazel or GitLab doesn't provide / expect / misses.Equally
A
1

I have no real solution for your problem, but some fixes (tested with Bazel 2.2.0):

Fix 1: Make use of mirrors

Host eigen yourself

I use now my own webserver to host eigen:

http_archive(
    name = "eigen",
    build_file = "//:eigen.BUILD",
    sha256 = "d56fbad95abf993f8af608484729e3d87ef611dd85b3380a8bad1d5cbc373a57",
    strip_prefix = "eigen-3.3.7",
    url = "http://vertexwahn.de/artifacts/eigen-3.3.7.tar.gz",
)

You can also add both urls:

http_archive(
    name = "eigen",
    build_file = "//:eigen.BUILD",
    sha256 = "d56fbad95abf993f8af608484729e3d87ef611dd85b3380a8bad1d5cbc373a57",
    strip_prefix = "eigen-3.3.7",
    urls = [
        "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz",
        "http://vertexwahn.de/artifacts/eigen-3.3.7.tar.gz",
    ],
)

Fix 2: Hold a local copy

Make use of --distdir.

Put eigen-3.3.7.tar.gz in a directory on your machine and use --disdir.

bazel build --distdir=X:\Dropbox\artifacts //...

Summary

Since you want never to be blocked by a dumb webserver you should implement some strategies on how to continue working when something like this happens.

Nevertheless, it would be interesting to find out why this 406 happens. You can use also use a Network sniffer (e.g. Wireshark) to get probably more details we the get request fails. I tried to find out more using Wireshark, but its an https connection and everything is encrypted - too bad.

Amylopectin answered 26/3, 2020 at 18:48 Comment(3)
One problem with the proposed Fix 1 is that bazel encounters an unrecoverable error from the 406. I've resolved this similarly using a mirror but had to comment out the gitlab URL in order for my builds to proceed.Harmonyharmotome
@Harmonyharmotome Which Bazel Version are you using?Amylopectin
I was using an ancient version of bazel (0.25.3) but I can confirm that the 3.1.0 release does not have this problem. Thanks!Harmonyharmotome
B
1

I also encountered this issue. I couldn't find any open issues for this on the bazel side, so I've opened one here.

Thanks to @fenollp for creating a reproduction.

Butte answered 22/4, 2020 at 12:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.