Skip to content
Latchkey

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.

bazel
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

  1. Replace hardcoded target lists with bazel query so patterns always match live targets.
  2. For changed-files builds, map files to targets with rdeps or query.
  3. Re-run so only existing targets are passed.
Terminal
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.

Frequently asked questions

What causes ""ERROR: Skipping ...: no such target""?
A CI script builds a list of targets (from changed files or a manifest) that still references a target that was renamed or deleted.
How do I fix "ERROR: Skipping ...: no such target"?
Regenerate the target list from a query

Related guides

References

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