如何在 Bazel 中删除缓存的下载对象(例如来自 http_archive)?

问题描述 投票:0回答:2

我的 Bazel C++ 项目的 CI 构建最近崩溃了。该错误表明

http_repository
的 HTTPS 下载失败:

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

我想在本地重现此错误,但我已经在本地缓存了该文件(下载错误似乎是间歇性的),所以我的本地构建成功了。

如何删除 Bazel 的

.tar.gz
文件缓存副本,以便在本地测试下载是否成功?我已经尝试过
bazel clean --expunge
但它似乎没有删除下载的工件。

bazel http-archive
2个回答
16
投票

rm -r $(bazel info repository_cache)
是暴力解决方案。将
--repository_cache=
传递给命令也应该禁用它。

文档中有 有关存储库缓存的更多信息。


0
投票

bazel clean --expunge

 应该清理你的缓存

© www.soinside.com 2019 - 2024. All rights reserved.