Grpc-gateway: Import "google/api/annotations.proto" was not found or had errors.

Created on 14 Mar 2018  路  4Comments  路  Source: grpc-ecosystem/grpc-gateway

Env: Windows 10

after follow step on this link https://github.com/grpc-ecosystem/grpc-gateway

on this steps on windows

protoc -I/usr/local/include -I. \
  -I$GOPATH/src \
  -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
  --go_out=plugins=grpc:. \
  path/to/your_service.proto

That I update to

protoc -IC:\Users\mossila\AppData\Local\ -I. -I%GOPATH%\src -I%GOPATH%\src\github.com\grpc-ecosystem\grpc-gateway\third_party\googleapis --go_out=plugins=grpc:. test-grpc.proto

I got this 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:28:8: "google.protobuf.MethodOptions" is not defined.
test-grpc.proto: Import "google/api/annotations.proto" was not found or had errors.

Which I don't know how to continue.

Most helpful comment

It is expected that /usr/local/include contains google/protobuf/descriptor.proto in the documentation.
I'm sorry but the documentation does not cover all the possible cases for simplicity.

In your case, could you replace /usr/local/include with the corresponding include path in your installation of protobuf?
For example, if you have the protoc at C:\Users\mossila\AppData\Local\protoc-3.5.1-win32\bin\protoc, could you try replacing the path with C:\Users\mossila\AppData\Local\protoc-3.5.1-win32\include?

All 4 comments

It is expected that /usr/local/include contains google/protobuf/descriptor.proto in the documentation.
I'm sorry but the documentation does not cover all the possible cases for simplicity.

In your case, could you replace /usr/local/include with the corresponding include path in your installation of protobuf?
For example, if you have the protoc at C:\Users\mossila\AppData\Local\protoc-3.5.1-win32\bin\protoc, could you try replacing the path with C:\Users\mossila\AppData\Local\protoc-3.5.1-win32\include?

@yugui Ok, It's work.
I have install protoc-3.5.1 at C:\dev\bin\ and I try to create service.pb.go with this command

protoc -IC:\dev\bin\protoc-3.5.1\include -I. -I%GOPATH%\src -I%GOPATH%\src\github.com\grpc-ecosystem\grpc-gateway\third_party\googleapis --go_out=plugins=grpc:. .\my-proto\my-service.proto

Next I try to Generate reverse-proxy

 protoc -IC:\dev\bin\protoc-3.5.1\include -I. -I%GOPATH%\src -I%GOPATH%\src\github.com\grpc-ecosystem\grpc-gateway\third_party\googleapis --grpc-gateway_out=logtostderr=true:. \my-proto\my-service.proto

All things work!
Thanks.

Congratulations!

thank your ,I too All things work!

Was this page helpful?
0 / 5 - 0 ratings