Home > Net >  protoc --dart_out=grpc:. -Iprotos helloworld.proto - directory does not exist
protoc --dart_out=grpc:. -Iprotos helloworld.proto - directory does not exist

Time:12-21

How do you specify a directory - the following only work if I put my helloworld.proto in a folder named protos

protoc --dart_out=. -Iprotos helloworld.proto
protos: warning: directory does not exist.
helloworld.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).

CodePudding user response:

You should not need to include -I in this case because helloworld.proto is in the current working directory.

-I (proto path) is used by protoc to reference directories that aren't in the current working directory. If you were to use ${PWD}/helloworld.proto for example, I think you'd need need to -I=${PWD}. Even though ${PWD} is equivalent to the current working directory, protoc sees a proto with a directory prefix and expects it to be added to the proto path.

Customarily, you'd need to add a proto path when you have protobuf imports that aren't local. Then, you add -I= and list the directories where these imports may be found.

  • Related