Skip to content
Latchkey

Bazel "Analysis of target failed" in CI

Bazel loaded the packages but analysis failed: a dependency does not provide what a rule expects, an attribute is invalid, or a visibility/constraint rule was violated.

What this error means

The build stops with "ERROR: Analysis of target //pkg:t failed; build aborted" preceded by a more specific message about an attribute, provider, or visibility problem.

bazel
ERROR: /workspace/apps/api/BUILD.bazel:5:10: in deps attribute of go_binary rule
//apps/api:api: '//libs/auth:auth' does not have mandatory provider 'GoLibrary'.
ERROR: Analysis of target '//apps/api:api' failed; build aborted

Common causes

Provider or rule-kind mismatch

A dep is the wrong rule kind for the attribute (for example a cc_library where a go_library is required), so it lacks the mandatory provider.

Invalid attribute value

An attribute is set to a disallowed value or type, which analysis rejects.

Visibility or constraint violation

A target depends on something it is not visible to, or a select() has no matching condition.

How to fix it

Read the specific analysis error above the summary

  1. The line before "Analysis of target failed" names the real problem.
  2. Fix the offending attribute, dependency kind, or visibility.

Inspect the dependency edge

  1. Query why the dependency is included and what it provides.
Terminal
bazel query 'somepath(//apps/api:api, //libs/auth:auth)'

How to prevent it

  • Match rule kinds across deps and keep visibility explicit so analysis errors surface in review, not CI.

Related guides

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