namely/docker-protoc

Google Protobufs not found

Closed this issue · 3 comments

I am having issues when trying to use Google Protobufs.

I have a proto file that looks like this.

syntax = "proto3";
import "google/protobuf/timestamp.proto";

package test.protobuf;

message Auditing {
    int32 createdByUserId = 1;
    google.protobuf.Timestamp createdDate = 2;
    int32 lastModifiedByUserId = 3;
    google.protobuf.Timestamp lastModifiedDate = 4;
}

But when I run the command

docker run  -v `pwd`:/defs namely/protoc-all \
	-d proto/dto -o ./src/main/java \
	-l java

I receive the response

google/protobuf/timestamp.proto: File not found.
auditing.proto:2:1: Import "google/protobuf/timestamp.proto" was not found or had errors.

Looking at the homepage Readme.md to this repository it says this protobuf library artifact is included in the docker image. Do I need to alter my command to include Google Protobufs?

this change isn't fixable in this repo, as google changed their upstream libraries. I suggest keeping all your protos together in a repo, including dependent ones like the google apis. This is outlined here: https://medium.com/@mhamrah/introducing-grpckit-and-omniproto-a-toolchain-for-your-grpc-needs-9a92bd358bf1

Protorepos: Monorepos for Protofiles

_Omniproto and gRPCkit are designed to work with protorepos, or monorepos for protofiles. As companies adopt gRPC, having a single source of truth for all protofiles is essential for collaboration. You are usually producing and consuming gRPC services, so having all protos in one place is helpful for generation that’s relevant to your language. More importantly, the entire company has insight into how the API, usually both internal and external, is evolving. CODEOWNERS on the protorepo can help with cross-company API stability and consistency, along with linting tools provided by buf or prototool.

The recommended pattern for using omniproto is to submodule your protorepo into your project’s code repository, and have an omniproto.yaml file at the root of your code repository, using your protorepo’s submodule as its source. Keep everything root-relative to your protorepo directory, and you’ll have consistent imports across files. gRPCkit intentionally does not include any protofiles outside of the standard Google proto types included with protocol buffers. Specifically, the Google Public APIs are excluded. You should include the files you need in your protorepo, to be explicit about your dependencies and what version they use._

Thanks @mhamrah , interesting article. I am trying to setup a monorepo for all my protofiles so this is very useful to me. Will try it out.

Seeing the same thing here. This has broken a whole bunch of builds. Can we have the protobuf includes in /opt/include just like the googleapis protos? I don't understand the justification for keeping google/protobuf omitted while including all of googleapis.