Skip to content

Error: failed to import google/api/annotations.proto #165

Closed
@prashcr

Description

I tried including the option syntax to my .proto file then I got this error when I tried running my gRPC Node.js server. It seems it has tried to execute the import as if it were referring to a local file in the current dir.

I'm also confused about the usage of this library. In Go, the generated .pb.go and .pb.gw.go seem to be imported and used by the proxy server which written in Go. How does this work when stubs of other languages are generated?

I love the idea of this library, and I thank you for your help!

/Users/prashanthcr/code/grpc_calculator/node_modules/protobufjs/dist/ProtoBuf.js:4640
                            throw Error("failed to import '"+importFilename+"' in '"+filename+"': file not found");
                            ^

Error: failed to import '/Users/prashanthcr/code/grpc_calculator/protos/google/api/annotations.proto' in '/Users/prashanthcr/code/grpc_calculator/protos/calculator.proto': file not found
    at Error (native)
    at ProtoBuf.Builder.BuilderPrototype.import (/Users/prashanthcr/code/grpc_calculator/node_modules/protobufjs/dist/ProtoBuf.js:4640:35)
    at Object.ProtoBuf.loadJson (/Users/prashanthcr/code/grpc_calculator/node_modules/protobufjs/dist/ProtoBuf.js:5135:26)
    at Object.ProtoBuf.loadProto (/Users/prashanthcr/code/grpc_calculator/node_modules/protobufjs/dist/ProtoBuf.js:5038:25)
    at Object.ProtoBuf.loadProtoFile (/Users/prashanthcr/code/grpc_calculator/node_modules/protobufjs/dist/ProtoBuf.js:5084:

proto

syntax = "proto3";

package calculator;

import "google/api/annotations.proto";

message Number {
  double value = 1;
}

message NumberPair {
  Number num1 = 1;
  Number num2 = 2;
}

service Calculator {
  rpc Add(NumberPair) returns (Number) {
    option(google.api.http) = {
      post: "/v1/add"
      body: "*"
    };
  }
  rpc Sub(NumberPair) returns (Number) {
    option(google.api.http) = {
      post: "/v1/sub"
      body: "*"
    };
  }
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions