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?

piarston
  • 1,685
  • 1
  • 13
  • 25
  • 1
    Does `wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz` work? – chtz Mar 26 '20 at 13:31
  • 1
    I have the same problem - wget works - http_archive gives me the same error (Bazel 2.2.0) – Vertexwahn Mar 26 '20 at 14:36
  • 6
    I confirm that wget works, but not bazel fetch – piarston Mar 26 '20 at 15:05
  • 1
    Reproducible with https://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. – fenollp Apr 20 '20 at 22:57

2 Answers2

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.

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
  • 2
    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. – murtis Mar 26 '20 at 21:14
  • @murtis Which Bazel Version are you using? – Vertexwahn Mar 27 '20 at 09:10
  • 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! – murtis May 21 '20 at 03:32
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.

Dig-Doug
  • 91
  • 8