bazel: http_archive gets 406 error, can download using browser
Description of the problem:
When trying to download an archive using http_archive
from a project on gitlab, I get a 406
error. However, I can download the archive using my browser.
Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I was able to reproduce with the code posted here.
cd /tmp
git clone https://github.com/fenollp/gitlab_bazel_406_on_download_and_extract.git
cd gitlab_bazel_406_on_download_and_extract
bazel sync
INFO: Repository radamsa instantiated at:
no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
/home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/bazel_tools/tools/build_defs/repo/http.bzl:336:16: in <toplevel>
WARNING: Download from https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2 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 'radamsa':
java.io.IOException: Error downloading [https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2] to /home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/radamsa/radamsa-v0.6.tar.bz2: GET returned 406 Not Acceptable
ERROR: java.io.IOException: Error downloading [https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2] to /home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/radamsa/radamsa-v0.6.tar.bz2: GET returned 406 Not Acceptable
Loading: loading...
What operating system are you running Bazel on?
Ubuntu 19.10
What’s the output of bazel info release
?
INFO: Invocation ID: 389ae0d8-4b39-4f14-8503-6725a9892926
release 3.1.0
What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?
https://github.com/fenollp/gitlab_bazel_406_on_download_and_extract.git
e31a3678cff03c3739722de0b143ff87996c55f5
e31a3678cff03c3739722de0b143ff87996c55f5
Have you found anything relevant by searching the web?
Other people have also encountered this issue:
However, none of the suggestions are fixes, just workarounds. This looks like a bug to me because I can download the archive fine with my browser.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 11
- Comments: 19 (9 by maintainers)
Commits related to this issue
- Provide an alternate mirror for eigen to work around https://github.com/bazelbuild/bazel/issues/11187 — committed to mjbots/bazel_deps by jpieper 4 years ago
- Added UserAgent to downloader HttpConnector The issue is outlined in #11187, but it seems like some servers expect a `User-Agent` to allow fetching archives, notably gitlab. This prevents bazel from ... — committed to bazelbuild/bazel by rdelfin 4 years ago
Strangely, downloading manually and then rerunning the bazel command seems to make it start working for me. (I’m running into this with Eigen.)