Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File does not reside within any path specified using proto_path

I am testing out importing .proto file from another directory.

$GOPATH/src/A/A.proto

syntax = "proto3"; 
package A;
 message SomeMsg {
     string  msg = 2;
     int64   id  = 3;
 }

$GOPATH/src/B/B.proto

syntax = "proto3"; 
package B; import "A/A.proto";
 message Msg {
     SomeMsg s = 1;
 }

I'm doing this: in folder A:

protoc A.proto --go_out=.

and then in folder B:

protoc B.proto --go_out=. --proto_path=$GOPATH/

But I will get this error:

B.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).

like image 302
Cubey Mew Avatar asked Jul 11 '18 13:07

Cubey Mew


1 Answers

Error seems clear enough to me, it is saying that you need to specify the exact directory that B.proto is in

protoc B.proto --go_out=. --proto_path=$GOPATH/src/B 

or if you are in folder B already,

protoc B.proto --go_out=.
like image 173
Popmedic Avatar answered Sep 19 '22 08:09

Popmedic