Skip to content
Latchkey

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.

Bazel
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 Y

Common 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

  1. Confirm the archive URL still resolves (or add a mirror).
  2. Update the sha256 to match the artifact actually served.
  3. Re-run; Bazel re-fetches the repository.
MODULE.bazel / WORKSPACE
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.

Terminal
bazel build //... --verbose_failures

How to prevent it

  • Pin correct sha256 checksums and keep them updated.
  • Mirror critical archives so a moved URL does not break fetches.
  • Cache the Bazel repository cache between CI runs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →