protoc-gen-validate icon indicating copy to clipboard operation
protoc-gen-validate copied to clipboard

Unable to install protoc-gen-validate

Open ocavue opened this issue 5 years ago • 7 comments

Dockerfile:

FROM golang:1.15-buster 
WORKDIR /data/

# install unzip
RUN apt-get update && apt-get install -y unzip

# install /usr/local/bin/protoc
RUN curl -L -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip && \
    unzip /tmp/protoc.zip -d /tmp/protoc/ && \
    mv /tmp/protoc/bin/protoc /usr/local/bin/ && \
    chmod +x /usr/local/bin/protoc

# install /go/bin/protoc-gen-go
RUN go get -u -v github.com/golang/protobuf/protoc-gen-go

# install /go/bin/protoc-gen-validate
# installing PGV can currently only be done from source
RUN go get -d github.com/envoyproxy/protoc-gen-validate && \
    cd $GOPATH/src/github.com/envoyproxy/protoc-gen-validate && \
    git log -n 1 && \
    make build

Error:

cd validate && protoc -I . \
	--plugin=protoc-gen-go=/go/src/github.com/envoyproxy/protoc-gen-validate/bin/protoc-gen-go \
	--go_opt=paths=source_relative \
	--go_out="Mvalidate/validate.proto=github.com/envoyproxy/protoc-gen-validate/validate,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers,Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor:." validate.proto
google/protobuf/descriptor.proto: File not found.

you can see the full log at https://github.com/ocavue/Dockerfiles/runs/1163927292#step:4:230

ocavue avatar Sep 25 '20 03:09 ocavue

I might have an answer to this particular issue. You will need to add the contents of the protoc/include directory as well into /usr/local ie RUN curl -L -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.1/protoc-3.13.1-linux-x86_64.zip && \ unzip -o /tmp/protoc.zip -d /usr/local bin/protoc && \ unzip -o /tmp/protoc.zip -d /usr/local 'include/*' && \ .. ..

deepakkrishnak avatar Oct 07 '20 20:10 deepakkrishnak

BTW, If I check out the code to v0.4.1 (12 Aug 2020), then the installation has no issue.

ocavue avatar Oct 12 '20 14:10 ocavue

Just ran some git bisect commands. It shows that this issue is caused by commit 538267e

I believe the reason is that github.com/golang/protobuf removed .proto files from their repository in this commit: https://github.com/golang/protobuf/commit/f5983a527bbdbebe09855e1915b229f67e529e23 and the new test in 538267e triggers this error.

ocavue avatar Oct 15 '20 21:10 ocavue

@akonradi I can think of two options to fix this issue:

  1. We can simply comment out those testing codes, so users will not fail when running make build
  2. It seems that users don't need to run make build locally to install PGV? I tried to run go get github.com/envoyproxy/protoc-gen-validate and everything is fine. What's the reason to let users run make build? I feel like that I missed something...

Any better ideas?

ocavue avatar Oct 15 '20 22:10 ocavue

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 16 '20 03:11 stale[bot]

@akonradi any update on this?

ocavue avatar Nov 16 '20 04:11 ocavue

The error message is correct, whether or not the bisect is fingering that commit. The well-known types are required by validate.proto in order to generate correctly.

As @deepakkrishnak was saing, where you're installing protoc into your docker image, the tarball should contain a directory including these protos that are typically installed at /usr/local/include/google/....

All that said, make build shouldn't need to execute protoc to generate the validate.pb.go, since it's included in the repo.

rodaine avatar Dec 17 '20 19:12 rodaine