Skip to content
Latchkey

Bazel "missing input file" in CI

A rule references a source file that is not present in the package directory. The file was renamed, deleted, or never committed to the CI checkout.

What this error means

Analysis or execution fails with "ERROR: <pkg>/BUILD.bazel: missing input file <label>". The build stops because a declared input cannot be found.

bazel
ERROR: /workspace/libs/auth/BUILD.bazel:3:11: in srcs attribute of
cc_library rule //libs/auth:auth: missing input file '//libs/auth:token.cc'

Common causes

Source renamed or deleted

A file listed explicitly in srcs/data was renamed or removed without updating the BUILD file, so the label no longer resolves to a real file.

File not committed to CI

The source exists locally but is untracked, so a clean CI checkout is missing it.

Generated file expected as a source

A file produced by another rule is listed as a plain source instead of referencing the generating target output.

How to fix it

Confirm the file is tracked and present

  1. Map the missing label to a path and check git tracks it.
  2. Stage and commit any new sources the BUILD references.
Terminal
git ls-files libs/auth/token.cc

Update srcs or use glob carefully

  1. Remove or rename the stale entry in srcs.
  2. Prefer glob() for source lists, but commit new matching files.

How to prevent it

  • Keep srcs in sync with the filesystem; CI catches drift if you run bazel build //... on every change.

Related guides

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