Skip to content

Conversation

@kolyshkin
Copy link
Contributor

Despite the ability to specify multiple include directories
in config.Include.After, the /usr/local/bin path to
google/protobuf/descriptor.proto is hardcoded in
func (*descriptorSet).marshalTo().

Fix by passing c.Config.After (i.e. list of user-supplied
include paths) to the above function, and iterate over those
to search for descriptor.proto.

This (together with the addition of /usr/include path to
config.Include.After) makes it possible to use protobuilder
with distro-installed protoc (e.g. with Debian/Ubuntu it is
apt install libprotobuf-dev protobuf-compiler).

@kolyshkin
Copy link
Contributor Author

@stevvooe PTAL

descriptors.go Outdated
return err
}

const descProto = "google/protobuf/descriptor.proto"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This search code should be outside of marshalTo. Could we just take this path as an argument to newDescriptorSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit I don't fully get it. Do you mean something like this (please see updated commit)?

If not, maybe you can create something based on the code/idea in this patch?

Go 1.11 and 1.10 are currently supported.

Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Despite the ability to specify multiple include directories
in `config.Include.After`, the `/usr/local/bin` path to
`google/protobuf/descriptor.proto` is hardcoded in
`func (*descriptorSet).marshalTo()`.

Fix by introducing a function to search for this file,
and providing the path found to newDesceriptorSet.

This (together with the addition of `/usr/include` path to
`config.Include.After`) makes it possible to use protobuilder
with distro-installed protoc (e.g. with Debian/Ubuntu it is
`apt install libprotobuf-dev protobuf-compiler`).

Signed-off-by: Kir Kolyshkin <[email protected]>
@stevvooe
Copy link
Member

@kolyshkin Thanks!

@kolyshkin
Copy link
Contributor Author

OK it's not good:

protoc --decode google.protobuf.FileDescriptorSet /usr/local/include/google/protobuf/descriptor.proto
/usr/local/include/google/protobuf/descriptor.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).

I can't reproduce it locally (for whatever reason) but it seems that ditching the -I was a mistake. I'll work on a followup PR to fix this.

This was referenced Oct 2, 2018
justai-net pushed a commit to justai-net/protobuild that referenced this pull request Dec 20, 2018
Don't hardcode path to google/protobuf/descriptor.proto
@justai-net
Copy link
Contributor

@kolyshkin didn't see your comment.

I opened a pull request as I also had the issue,

#23

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 this pull request may close these issues.

3 participants