Bazel "no such package" / repo mapping in CI
Bazel resolved a label to a package and found no BUILD (or BUILD.bazel) file there, or the external repository named in the label is not declared. Without a package definition, Bazel cannot load any target.
What this error means
A build fails with "ERROR: no such package 'path': BUILD file not found" or "no such package '@repo//...': The repository '@repo' could not be resolved".
Bazel
ERROR: no such package 'libs/util': BUILD file not found in any of the
following directories. libs/utilCommon causes
No BUILD file at the package path
The directory has no BUILD or BUILD.bazel, so Bazel does not recognize it as a package.
An undefined external repository
A @repo//... label points at an external repo that is not declared in MODULE.bazel or WORKSPACE, so it cannot be resolved.
How to fix it
Add the missing BUILD file
- Create a
BUILD.bazelin the package directory the label points at. - Declare the targets the label references.
- Re-run the build.
Terminal
touch libs/util/BUILD.bazelDeclare the external repository
Add the module (Bzlmod) or repository rule so the @repo reference resolves.
MODULE.bazel
bazel_dep(name = "rules_go", version = "0.46.0")How to prevent it
- Add a BUILD file to every directory you reference as a package.
- Declare external repos in
MODULE.bazelbefore using@repo//labels. - Use
bazel queryto confirm a package loads.