Skip to content
Latchkey

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.

protoc
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

  1. Decide the target language and output directory.
  2. Add the matching --<lang>_out flag with a concrete path.
  3. Re-run protoc and confirm files are written.
Terminal
protoc -I proto --go_out=gen/go proto/service.proto

Guard interpolated output paths

If the output directory comes from a variable, fail early when it is empty rather than letting protoc see no directive.

Terminal
OUT_DIR="${OUT_DIR:?OUT_DIR must be set}"
protoc -I proto --go_out="$OUT_DIR" proto/service.proto

How to prevent it

  • Always pass a concrete --<lang>_out flag in the codegen command.
  • Validate interpolated path variables before invoking protoc.
  • Prefer a buf generate config over long hand-written protoc commands.

Frequently asked questions

What causes ""Missing output directives""?
The invocation passes input files and -I import paths but forgot the actual generator flag such as --go_out, --cpp_out, or --python_out.
How do I fix "Missing output directives"?
Add an explicit output directive

Related guides

References

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