I have a project using grpc-gateway that was building correctly fairly recently, however when I set everything up from scratch on a new laptop I'm unable to build due the following error:
google/protobuf/descriptor.proto: File not found.
google/api/annotations.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
google/api/annotations.proto:26:8: "google.protobuf.MethodOptions" is not defined.
proto/lead.proto: Import "google/api/annotations.proto" was not found or had errors.
I'm on OSX, and set up everything as such:
wget https://github.com/google/protobuf/releases/download/v3.0.0-beta-3/protoc-3.0.0-beta-3-osx-x86_64.zip
mkdir temp
unzip -d temp protoc-3.0.0-beta-3-osx-x86_64.zip
mv temp/protoc /usr/local/bin
rm -rf temp
rm protoc-3.0.0-beta-3-osx-x86_64.zip
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
And I've been attempting to generate as follows:
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
proto/*.proto
The .proto:
syntax = "proto3";
package prequal;
import "google/api/annotations.proto";
service PrequalSvc {
rpc Prequal(PrequalRequest) returns (PrequalResponse) {
option (google.api.http) = {
post: "/api/v1/prequal"
body: "*"
};
}
}
Did I miss something in the setup?
PEBKAC, I'm an idiot.
If you just copy protoc without anything else in to /usr/local/bin, you're going to be missing a lot of stuff/have a bad time.
um, what else should I have copied, and where to?
@dmlyons I think the important thing is that the directory containing protoc should be on your PATH. @brianstarke can you confirm for posterity?
Yes, it was some time ago - but I believe that was the fix - my current rc has
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
And I've been building fine for months.
I have the same problem, could you please elaborate on your fix? I have used the --go_path to my workspace on customized go installation location.
@brianstarke you are a live saver. I thought I had grown past issues like this.
I believe that the solution refereneced here is to install from source, as described here.
~/Downloads/protoc $ sudo cp -r bin include /usr/local/
On CentOS7 i installed protobuf-devel-3.6.1-4.el7.x86_64.rpm and it resolved my issue.
Most helpful comment
PEBKAC, I'm an idiot.
If you just copy
protocwithout anything else in to/usr/local/bin, you're going to be missing a lot of stuff/have a bad time.