Skip to content
Latchkey

protoc "google/protobuf/...proto: File not found / had errors" in CI

protoc resolves every import against the directories given with -I / --proto_path. When an imported file (often a well-known type like google/protobuf/timestamp.proto) is not on any include path, protoc reports it as not found and aborts.

What this error means

protoc prints "<path>.proto: File not found." and then "Import "<path>.proto" was not found or had errors." for the file that imports it.

protoc
google/protobuf/timestamp.proto: File not found.
api/service.proto:5:1: Import "google/protobuf/timestamp.proto" was not found or had errors.

Common causes

The well-known types include path is missing

Imports under google/protobuf/ live next to the protoc install (its include directory). If that directory is not passed with -I, the import cannot resolve.

A local import path is not on --proto_path

A first-party import is relative to a proto root that was never added with -I, so protoc looks in the wrong place.

How to fix it

Add every proto root to the include path

  1. Add your proto source root with -I.
  2. Add the well-known types include directory shipped with protoc.
  3. Re-run so all imports resolve against a known root.
Terminal
protoc -I proto -I /usr/include \
  --go_out=gen/go proto/api/service.proto

Let buf manage imports and dependencies

buf resolves well-known types and remote dependencies from buf.yaml, so you do not hand-manage include paths.

buf.yaml
# buf.yaml
version: v1
deps:
  - buf.build/googleapis/googleapis

How to prevent it

  • Pass both your proto root and the protoc include directory with -I.
  • Keep import paths relative to a single declared proto root.
  • Use buf so well-known and third-party protos resolve from config.

Frequently asked questions

What causes ""was not found or had errors""?
Imports under google/protobuf/ live next to the protoc install (its include directory). If that directory is not passed with -I, the import cannot resolve.
How do I fix "was not found or had errors"?
Add every proto root to the include path

Related guides

References

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