buf "buf build" Failure compile error in CI
buf build compiles every proto in the module into an image. A compile Failure names the file, line, and column of a syntax error or an import that buf could not resolve from the module roots and dependencies.
What this error means
buf build fails with "Failure:" followed by a file:line:col message such as a missing semicolon, an unknown type, or an import that could not be resolved.
api/v1/user.proto:9:3:field name "email" is already in use by field "1"
Failure: compile errorCommon causes
A syntax or semantic error in a proto
A duplicate field number, unknown type, or missing token stops compilation at the location buf reports.
An import buf cannot resolve
A referenced file is neither in the module nor in a declared dependency, so buf cannot build the image.
How to fix it
Fix the reported location
- Open the file at the reported line and column.
- Correct the syntax or resolve the duplicate/unknown symbol.
- Re-run
buf builduntil it succeeds.
Declare the dependency in buf.yaml
If the error is an unresolved import, add the module that provides it to buf.yaml deps and run buf dep update.
version: v2
deps:
- buf.build/googleapis/googleapisHow to prevent it
- Run
buf buildlocally before pushing to catch compile errors early. - Declare every external import as a buf.yaml dependency.
- Keep buf.lock committed so dependency versions are pinned.