Skip to content
Latchkey

Bazel "error loading package" in CI

Bazel reached the BUILD file but could not evaluate it. A Starlark error, a failed load() of a .bzl, or an undefined symbol stops the package from loading.

What this error means

Loading fails with "error loading package <pkg>:" followed by a Starlark traceback pointing at a line in a BUILD or .bzl file. The build never reaches analysis.

bazel
ERROR: error loading package 'libs/auth': Unable to load file
'@rules_go//go:def.bzl': no such file or directory
ERROR: Skipping '//libs/auth:all': error loading package 'libs/auth'

Common causes

load() points at a missing or wrong file

A load() statement references a .bzl file or repository that does not exist or was renamed, so evaluation fails before any target is defined.

Starlark syntax or symbol error

A typo, missing import, or undefined name in the BUILD/.bzl file raises a Starlark error during loading.

Repository not declared

The @repo in a load() is not defined in WORKSPACE or MODULE.bazel, so the file cannot be resolved.

How to fix it

Read the traceback to the failing line

  1. Open the BUILD or .bzl file named in the error at the reported line.
  2. Fix the load path, symbol, or syntax it points to.

Verify the loaded repo and symbol exist

  1. Confirm the @repo is declared in MODULE.bazel or WORKSPACE.
  2. Confirm the .bzl exports the symbol you load.
Terminal
bazel query '@rules_go//go:def.bzl'

How to prevent it

  • Run buildifier and a bazel query //... in CI so load and Starlark errors surface before merge.

Frequently asked questions

What causes ""error loading package""?
A load() statement references a .bzl file or repository that does not exist or was renamed, so evaluation fails before any target is defined.
How do I fix "error loading package"?
Read the traceback to the failing line

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card