6

The CI build for my Bazel C++ project recently broke. The error indicates that the HTTPS download for a http_repository failed:

INFO: Repository eigen instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_kstaley/efca2582089f638162aa9f6ccfe4282e/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
WARNING: Download from https://gitlab.com/libeigen/eigen/-/archive/56b3e3f3f8ca9972ca390c8296fde363bdab271c/eigen-56b3e3f3f8ca9972ca390c8296fde363bdab271c.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/56b3e3f3f8ca9972ca390c8296fde363bdab271c/eigen-56b3e3f3f8ca9972ca390c8296fde363bdab271c.tar.gz] to /private/var/tmp/_bazel_kstaley/efca2582089f638162aa9f6ccfe4282e/external/eigen/eigen-56b3e3f3f8ca9972ca390c8296fde363bdab271c.tar.gz: GET returned 406 Not Acceptable
ERROR: /Users/kstaley/src/myrepo/library/utilities/BUILD:58:11: //library/utilities:mylibrary depends on @eigen//:eigen in repository @eigen which failed to fetch. no such package '@eigen//': java.io.IOException: Error downloading [https://gitlab.com/libeigen/eigen/-/archive/56b3e3f3f8ca9972ca390c8296fde363bdab271c/eigen-56b3e3f3f8ca9972ca390c8296fde363bdab271c.tar.gz] to /private/var/tmp/_bazel_kstaley/efca2582089f638162aa9f6ccfe4282e/external/eigen/eigen-56b3e3f3f8ca9972ca390c8296fde363bdab271c.tar.gz: GET returned 406 Not Acceptable
ERROR: Analysis of target '//library/mypackage:mybinary' failed; build aborted: Analysis failed

I would like to reproduce this error locally, but I already have that file cached locally (the download error seems to be intermittent), so my local build succeeds.

How can I delete Bazel's cached copy of the .tar.gz file so that I can test whether the download succeeds locally? I've tried bazel clean --expunge but it does not seem to delete downloaded artifacts.

Kerrick Staley
  • 1,583
  • 2
  • 20
  • 28

1 Answers1

15

rm -r $(bazel info repository_cache) is the brute force solution. Passing --repository_cache= to commands should also disable it.

There's more about the repository cache in the documentation.

Benjamin Peterson
  • 19,297
  • 6
  • 32
  • 39
  • From my testing, it looks like `rm -r $(bazel info repository_cache)` did work, but `--repository_cache=` didn't. It's a little hard to repro this though so it's possible I'm wrong. Could you double check whether `--repository_cache=` works and update your answer accordingly? – Kerrick Staley Jul 21 '20 at 04:54
  • There may be a bug, where `--repository_cache=` doesn't have effect unless the server is restarted. – Benjamin Peterson Jul 21 '20 at 14:03