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.
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
- Add your proto source root with
-I. - Add the well-known types include directory shipped with protoc.
- Re-run so all imports resolve against a known root.
protoc -I proto -I /usr/include \
--go_out=gen/go proto/api/service.protoLet 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
version: v1
deps:
- buf.build/googleapis/googleapisHow 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.