Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to set the path to the protoc to import standards Protocol Buffers

Where need I to set the path to the protoc to get import standards Protocol Buffers (protobuf), like empty.proto and timestamp.proto in Windows and Dart?

When the protoc is ran:

protoc --dart_out=grpc:lib/src/protos/generated -Iprotos protos/organization.proto --plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc-gen-dart.bat

The following error is presented:

google/protobuf/empty.proto: File not found. organization.proto: Import "google/protobuf/empty.proto" was not found or had errors. organization.proto:14:27: "google.protobuf.Empty" is not defined.

In IntelliJ Settings on Protobuf Support plugin the path is define where standard protos (*.proto) are:

enter image description here

Additionally this path is define in IntelliJ on Project Structure \ Global Libraries:

enter image description here

The code organization.proto that import google/protobuf/empty.proto to use Empty class :

syntax = "proto3";

package auge.protobuf;

import "google/protobuf/empty.proto";

service OrganizationService {

    rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}

IntelliJ analyzer recognizes the import "google/protobuf/empty.proto" and Empty class on IDEA, but protoc can not find.

The environment is:

  • SO: Windows 7 x64
  • protoc: libprotoc 3.6.1
  • Dart: 2.2.0-edge
like image 719
Muka Avatar asked Feb 17 '19 19:02

Muka


1 Answers

Say you have /some/path/to/google/protobuf/empty.proto, you need to pass --proto_path=/some/path/to/ so protoc can locate it.

like image 179
Igor Gatis Avatar answered Sep 23 '22 07:09

Igor Gatis