protoc "Import X was not found or had errors" in CI
protoc reports this on the importing file when a dependency it pulls in either cannot be found on the import path or itself failed to compile. Fix the imported file (or its path) first; this error clears once the dependency parses.
What this error means
protoc prints "api/v1/user.proto:5:1: Import \"common/types.proto\" was not found or had errors." usually alongside a "File not found" or a parse error on the imported proto.
common/types.proto:3:8: Expected "required", "optional", or "repeated".
api/v1/user.proto:5:1: Import "common/types.proto" was not found or had errors.Common causes
The imported file is not on the import path
A missing -I root means protoc cannot find the dependency, so it flags the importing file as having a bad import.
The imported file has its own compile error
When the dependency fails to parse, protoc cannot compile the importer either; the real error is on the imported file above this line.
How to fix it
Fix the dependency error first
- Read the error printed on the imported file above this message.
- Correct that syntax or path error.
- Re-run protoc; the "had errors" cascade clears once the import compiles.
Ensure the import root is on the path
If the imported file is fine, add the directory that makes its import path resolve with -I.
protoc -I proto -I common --go_out=gen proto/api/v1/user.protoHow to prevent it
- Compile leaf protos first so dependency errors surface directly.
- Keep every import root on
-Iin both local and CI runs. - Use
buf buildwhich reports the underlying error with clearer location info.