Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc is failing due to inability to find extensions.proto #312

Closed
pgautier404 opened this issue May 25, 2023 · 3 comments · Fixed by #332
Closed

protoc is failing due to inability to find extensions.proto #312

pgautier404 opened this issue May 25, 2023 · 3 comments · Fixed by #332
Assignees

Comments

@pgautier404
Copy link
Contributor

cachepubsub.proto is importing extensions.proto, but for some reason protoc is unable to find that file, despite the fact that it's in the same directory as the others. Here's the relevant output from running make protos in the golang SDK root:

protoc -I=internal --go_out=internal --go_opt=paths=source_relative --go-grpc_out=internal --go-grpc_opt=paths=source_relative internal/protos/*.proto
extensions.proto: File not found.
protos/cachepubsub.proto:3:1: Import "extensions.proto" was not found or had errors.

I had a similar issue trying to run protoc in the web SDK, and in that case I was able to resolve the error by adding extensions.proto as the first proto file in an explicit list of files to compile. However, that approach doesn't work with golang, and the error is returned regardless of whether or not I compile extensions.proto before cachepubsub.proto.

@cprice404 cprice404 changed the title protoc is failing due to inability to fine extensions.proto protoc is failing due to inability to find extensions.proto May 25, 2023
@kvcache
Copy link
Contributor

kvcache commented May 25, 2023

So, first place to look:

$ protoc --help
Usage: protoc [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
  -IPATH, --proto_path=PATH   Specify the directory in which to search for
                              imports.  May be specified multiple times;
                              directories will be searched in order.  If not
                              given, the current working directory is used.
                              If not found in any of the these directories,
                              the --descriptor_set_in descriptors will be
                              checked for required proto file.

Then, to understand how that works you can refer to the relevant part of the spec for the feature that isn't working as you expect:
https://protobuf.dev/programming-guides/proto3/#importing

The protocol compiler searches for imported files in a set of directories specified on the protocol compiler command line using the -I/--proto_path flag.

Looking at your proto, you can see that it is referring to a path directly at the root of an import tree:
https://github.com/momentohq/client-sdk-go/blob/main/internal/protos/cachepubsub.proto#L3

import "extensions.proto";

However your invocation is:

protoc -I=internal [...]

protoc looks for extensions.proto at internal/extensions.proto per the documentation, and it is not found because that's not where that file is in this repository. In fact, I'm not sure there is anything this invocation can use via that -I directive? Why isn't this using -I=internal/protos?

@pratik151192
Copy link
Contributor

pratik151192 commented Jul 5, 2023

In fact, I'm not sure there is anything this invocation can use via that -I directive? Why isn't this using -I=internal/protos?

I experienced the same and did not see the error after changing the proto_path or -I directive to internal/protos . However, --go_out and --go-grpc_out should also be internal/protos and not internal. The MakeFile suggests to use those options for protoc, the same one which @pgautier404 has posted. I believe it should change to

protoc -I=internal/protos --go_out=internal/protos --go_opt=paths=source_relative --go-grpc_out=internal/protos --go-grpc_opt=paths=source_relative internal/protos/*.proto

I am not sure how we were developing before though. The MakeFile also needs to be updated in that case. For me a bunch of methods also changed from protos_auth_proto signature to auth_proto so not 100% if this is ideal.

@pratik151192
Copy link
Contributor

So @pgautier404 and I verified the diff on the proto generated files and it is doing the right thing. The MakeFile was updated with the updated commands to internal/protos as a part of this PR #332. This issue can be closed.

@pratik151192 pratik151192 self-assigned this Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants