Grpc-gateway: Please help: google/api/annotations.proto: File not found.

Created on 20 Dec 2016  路  5Comments  路  Source: grpc-ecosystem/grpc-gateway

Hi,

I am a grpc newbie, like gprc and am looking forward to auto-generate REST API from my .proto files.

I am probably making some mistake in my setup. Could you please take a look and help? Am I missing a package? Am I invoking the protoc with incorrect params?

My setup details are below.

I am unable to compile the .proto file with the annotation.

Building proto files...
google/api/annotations.proto: File not found.
serverrpc.proto: Import "google/api/annotations.proto" was not found or had errors.

-- My script

export SCRIPTDIR=/libera
export GOPATH=$SCRIPTDIR
echo "Building proto files..."
export PATH=$PATH:$SCRIPTDIR/bin
cd $SCRIPTDIR/bin
protoc -I$SCRIPTDIR/src/server/rpcdef/ \
-I$SCRIPTDIR/src/vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=$SCRIPTDIR/src/server/rpcdef $SCRIPTDIR/src/server/rpcdef/serverrpc.proto

-- Directory layout

[root@63f0407abe77 libera]# pwd
/libera
[root@63f0407abe77 libera]# ls bin/
gvt protoc protoc-gen-go protoc_bk server.log
[root@63f0407abe77 libera]#
[root@63f0407abe77 libera]# ls src/server/rpcdef/
serverrpc.pb.go serverrpc.proto

The vendor dir below has all the packages required:

[root@63f0407abe77 src]# pwd
/libera/src
[root@63f0407abe77 src]# ls vendor/
cloud.google.com github.com go4.org golang.org google.golang.org gopkg.in manifest

-- serverrpc.proto file

1 syntax = "proto3";
2
3 package serversvc;
4
5 import "google/api/annotations.proto";
6
7 // The greeting service definition.
8 service ServerSvc {
9 // Sends a greeting
10 rpc GetStatus (ServerSvcStatusRequest) returns (ServerSvcStatusResponse) {
11 option (google.api.http) = {
12 post: "/v1/getstatus"
13 body: "*"
14 };
15 }

[root@63f0407abe77 bin]# ./protoc --version
libprotoc 3.1.0

Most helpful comment

@pzsfeng I think you are missing the import part in your protoc command

--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:.

I believe this ^ maps github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis to google/api/annotations.proto

This is from the README

All 5 comments

@pzsfeng I think you are missing the import part in your protoc command

--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:.

I believe this ^ maps github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis to google/api/annotations.proto

This is from the README

@fiibbb Thanks for taking a look.

I think you are missing the import part in your protoc command

I didn't quite understand it. Could you please mention how to invoke it? Thanks.

Just doing a little bit of tidying. I hope that your question was answered in a way that let your project continue. If you have any more questions feel free to reopen this issue.

妤间富杩欎釜瑙e喅浜嗗悧锛熸垜鏄柊鎵嬶紝涔熼亣鍒拌繖鏍风殑闂
image

Hi @cappucino5. Please reach out for help with this type of matter on chat services such as Gophers slack channel. This is not the best medium for this kind of debugging.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arun0009 picture arun0009  路  3Comments

danforbes picture danforbes  路  4Comments

stevenroose picture stevenroose  路  3Comments

Aleksion picture Aleksion  路  3Comments

silentAllay picture silentAllay  路  4Comments