Bazel "ERROR: Skipping ...: no such target" pattern in CI
A target pattern you passed (often on the command line or from a changed-files list) matched a label Bazel cannot resolve, so it prints "Skipping" and refuses to expand that pattern. The pattern that failed is quoted in the message.
What this error means
Bazel prints "ERROR: Skipping '//foo:bar': no such target '//foo:bar'" and may abort the invocation because a requested pattern did not match any target.
ERROR: Skipping '//foo:bar': no such target '//foo:bar': target 'bar' not declared
in package 'foo' defined by /home/runner/work/app/app/foo/BUILD.bazel
ERROR: no such target '//foo:bar'Common causes
A stale target in a generated pattern list
A CI script builds a list of targets (from changed files or a manifest) that still references a target that was renamed or deleted.
A pattern that matches a package with no such target
The explicit label on the command line does not exist in the package it names, so the pattern expands to nothing.
How to fix it
Regenerate the target list from a query
- Replace hardcoded target lists with
bazel queryso patterns always match live targets. - For changed-files builds, map files to targets with
rdepsorquery. - Re-run so only existing targets are passed.
bazel query 'kind(".*_test", //...)'Correct or drop the stale pattern
Fix the label to an existing target, or remove it from the list your CI passes to Bazel.
How to prevent it
- Derive target patterns from
bazel query, not static lists. - Keep changed-files-to-target mappings query based so they stay accurate.
- Fail CI early if a query returns no targets when it should.