Bazel "Repository rule ... failed" in CI
Bazel ran a repository rule to fetch or configure an external dependency and the rule's implementation failed. A download error, a checksum mismatch, or a failing setup command inside the rule stops the fetch phase.
What this error means
A build fails during loading with "ERROR: An error occurred during the fetch of repository 'X'" or "Repository rule X failed", followed by the underlying download or command error.
ERROR: An error occurred during the fetch of repository 'com_google_absl':
Traceback (most recent call last):
...
java.io.IOException: Error downloading [...] to ...: Checksum was X but wanted YCommon causes
A download or checksum failure
The archive URL is unreachable, moved, or its content no longer matches the pinned sha256, so the rule aborts.
A failing command inside the rule
A ctx.execute step (patch, configure, or codegen) in the repository rule returned non-zero during setup.
How to fix it
Fix the URL and checksum
- Confirm the archive URL still resolves (or add a mirror).
- Update the
sha256to match the artifact actually served. - Re-run; Bazel re-fetches the repository.
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.0.tar.gz"],
sha256 = "<correct-sha256>",
)Debug the rule setup
Re-run with --verbose_failures to see the failing command inside the repository rule, then fix that step.
bazel build //... --verbose_failuresHow to prevent it
- Pin correct
sha256checksums and keep them updated. - Mirror critical archives so a moved URL does not break fetches.
- Cache the Bazel repository cache between CI runs.