Where to set the path to the protoc to import standards Protocol Buffers
Asked Answered
W

2

9

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
Waldenses answered 17/2, 2019 at 19:38 Comment(0)
E
1

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

Emmetropia answered 11/8, 2021 at 0:23 Comment(0)
A
-1

use two dot before protobuf folder path

<Protobuf Include="..\Proto\protobuf.proto" ProtoRoot="Proto" />
Aggappora answered 4/5, 2022 at 6:44 Comment(1)
This is in C#/Visual Studio project, nothing related to Dart.Notation

© 2022 - 2025 — McMap. All rights reserved.