Skip to content
Latchkey

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/util

Common 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

  1. Create a BUILD.bazel in the package directory the label points at.
  2. Declare the targets the label references.
  3. Re-run the build.
Terminal
touch libs/util/BUILD.bazel

Declare 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.bazel before using @repo// labels.
  • Use bazel query to confirm a package loads.

Related guides

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