Muka
Muka

Reputation: 1200

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:

Upvotes: 9

Views: 5333

Answers (2)

xxxsenatorxxx
xxxsenatorxxx

Reputation: 123

use two dot before protobuf folder path

<Protobuf Include="..\Proto\protobuf.proto" ProtoRoot="Proto" />

Upvotes: -1

Igor Gatis
Igor Gatis

Reputation: 4898

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

Upvotes: 1

Related Questions