protoc "Missing output directives" in CI
protoc needs at least one output directive (a --<lang>_out flag) to know what to generate. When the command lists proto files but no _out flag, protoc prints "Missing output directives." and does nothing.
What this error means
protoc exits non-zero immediately with "Missing output directives." even though the .proto paths and imports are correct.
Missing output directives.Common causes
No --*_out flag in the command
The invocation passes input files and -I import paths but forgot the actual generator flag such as --go_out, --cpp_out, or --python_out.
A shell variable expanded to empty
A flag like --go_out=$OUT_DIR collapsed because OUT_DIR was unset in CI, leaving protoc with no usable output directive.
How to fix it
Add an explicit output directive
- Decide the target language and output directory.
- Add the matching
--<lang>_outflag with a concrete path. - Re-run protoc and confirm files are written.
protoc -I proto --go_out=gen/go proto/service.protoGuard interpolated output paths
If the output directory comes from a variable, fail early when it is empty rather than letting protoc see no directive.
OUT_DIR="${OUT_DIR:?OUT_DIR must be set}"
protoc -I proto --go_out="$OUT_DIR" proto/service.protoHow to prevent it
- Always pass a concrete
--<lang>_outflag in the codegen command. - Validate interpolated path variables before invoking protoc.
- Prefer a
buf generateconfig over long hand-written protoc commands.