6

My proto file is:

syntax = "proto3";

import "google/protobuf/timestamp.proto";

service Foo {
  rpc now(NowRequest) returns (NowResponse) {}
}

message NowRequest {}

message NowResponse {
  google.protobuf.Timestamp now = 1;
}

My command to generate code and the resulting error is:

protoc foo.proto --go_out=plugins=grpc,import_path=proto:internal/proto
foo.proto:3:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
foo.proto:12:3: "google.protobuf.Timestamp" is not defined.

My protoc version is:

protoc --version
libprotoc 3.11.3

I have followed this guide and reviewed this question. How can I import well known types? Do I need to download anything else? How can I tell what are the exact well known types for my current installation? Thank you.

Vitaly Isaev
  • 5,392
  • 6
  • 45
  • 64
user2133814
  • 2,431
  • 1
  • 24
  • 34

1 Answers1

8

"google/protobuf/timestamp.proto" gets stored in the path : /usr/local/include/google/protobuf

Please check if you have /usr/local/include/google/protobuf directory.

If not, this means there is an error in protobuf installation. Please retrace the installation steps followed or try re-installing.

Please find more help here : https://github.com/grpc-ecosystem/grpc-gateway/issues/422

Kartavya Ramnani
  • 800
  • 9
  • 17
  • 1
    What is the equivalent of this path (`/usr/local/include`) in **Windows**? I have a similar problem but in the Windows OS. Where should I put protobuf`s proto files? – Nurzhan Nogerbek Apr 29 '20 at 10:40
  • 1
    It would be nice if the documentation mentioned this. I tried following two of the tutorials, one for Go and one for Java, since those are languages that my organization uses. Neither tutorial explained where the imports came from, and one area of the reference section of the docs said something like "for details, see `google/profobuf/descriptors.proto`" (but where is that file?!). Eventually I found this Stack Overflow answer after trying to google for where the imports come from. – Matt Welke Feb 09 '21 at 04:37
  • I agree @MattWelke, glad this answer helped. – Kartavya Ramnani Feb 10 '21 at 08:51