【问题标题】:protoc --dart_out=grpc:. -Iprotos helloworld.proto - directory does not exist协议 --dart_out=grpc:。 -Iprotos helloworld.proto - 目录不存在
【发布时间】:2022-01-22 01:47:01
【问题描述】:

你如何指定一个目录 - 只有当我将我的 helloworld.proto 放在名为 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).

【问题讨论】:

    标签: dart grpc protoc


    【解决方案1】:

    在这种情况下您不需要包含-I,因为helloworld.proto 位于当前工作目录中。

    -I(原始路径)被protoc 用于引用不在当前工作目录中的目录。例如,如果您要使用${PWD}/helloworld.proto,我认为您需要-I=${PWD}。即使${PWD} 等同于当前工作目录,protoc 也会看到带有目录前缀的 proto,并希望将其添加到 proto 路径中。

    通常,当您有非本地的 protobuf 导入时,您需要添加一个 proto 路径。然后,添加 -I= 并列出可以找到这些导入的目录。

    【讨论】:

      猜你喜欢
      • 2020-04-28
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 2010-12-28
      • 2017-04-01
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多