Bazel "Failed to load Starlark extension" in CI
A load() statement referenced a .bzl file by label, and Bazel could not resolve it. The extension label points at a repository or path that is missing, so loading fails before analysis.
What this error means
A build fails with "ERROR: Failed to load Starlark extension '@repo//path:file.bzl'" and a note that the repository or file cannot be found.
bazel
ERROR: Failed to load Starlark extension '@rules_foo//foo:defs.bzl'.
Cycle in the load graph or the repository '@rules_foo' could not be resolved.
It may not have been defined in MODULE.bazel or WORKSPACE.Common causes
The repository was never declared or fetched
The @rules_foo repo in the load label is not defined in MODULE.bazel/WORKSPACE, so Bazel cannot find the .bzl file.
A wrong label path to the extension
The path or file name in the load label is incorrect, so the .bzl file does not exist at that location.
How to fix it
Declare the repository the extension lives in
- Add the missing module or repo to MODULE.bazel (or WORKSPACE).
- Confirm the load label path matches a real .bzl file in that repo.
- Re-run so the extension resolves and loads.
MODULE.bazel
bazel_dep(name = "rules_foo", version = "1.2.0")Correct the load label
Fix the repository name and path so the label points at an existing .bzl file.
foo/BUILD.bazel
load("@rules_foo//foo:defs.bzl", "foo_binary")How to prevent it
- Declare every repository referenced by a load statement.
- Keep load label paths in sync with the extension file locations.
- Run analysis in CI so unresolved loads fail before deploy.
Related guides
Bazel "Error computing the main repository mapping" in CIFix Bazel "ERROR: Error computing the main repository mapping" in CI - a WORKSPACE or MODULE.bazel evaluation…
Bazel "error loading package" during evaluation in CIFix Bazel "ERROR: error loading package" in CI - a BUILD file failed to evaluate because of a Starlark error,…
Bazel bzlmod "module not found in registry" in CIFix Bazel bzlmod "module ... not found in registries" in CI - a bazel_dep names a module or version that the…