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

Avoid passing both the short and the long proto paths to protoc #58

Closed
Tracked by #10005
iirina opened this issue Feb 19, 2018 · 5 comments
Closed
Tracked by #10005

Avoid passing both the short and the long proto paths to protoc #58

iirina opened this issue Feb 19, 2018 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@iirina
Copy link

iirina commented Feb 19, 2018

Currently for each .proto file Bazel passes to protoc the path relative to the workspace (the long path) via -I flag (alias for --proto_path).

Since 15a4362, Bazel also passes to protoc a short path via the --proto_path flag. The short path is only passed for proto_library targets that have set proto_source_root.

Passing to protoc both the short and the long path to a .proto file is error prone. A better mechanism must be implemented to deal with these situations.

@iirina iirina self-assigned this Feb 19, 2018
@iirina
Copy link
Author

iirina commented Feb 19, 2018

More context in bazelbuild/bazel#4544.

@wjywbs
Copy link

wjywbs commented Sep 28, 2018

Ping for this bug.

I'm importing protobuf code to //third_party/protobuf, but the proto_library rule [1] fails to build. Adding proto_source_root="third_party/protobuf" doesn't fix the build. The failing command is:

bazel-out/host/bin/third_party/protobuf/protoc '--proto_path=third_party/protobuf' '--descriptor_set_out=bazel-out/k8-opt/genfiles/third_party/protobuf/type_proto-descriptor-set.proto.bin' '-Ithird_party/protobuf/google/protobuf/type.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/type.proto' '-Ithird_party/protobuf/google/protobuf/any.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/any.proto' '-Ithird_party/protobuf/google/protobuf/source_context.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/source_context.proto' --direct_dependencies third_party/protobuf/google/protobuf/any.proto:third_party/protobuf/google/protobuf/source_context.proto:third_party/protobuf/google/protobuf/type.proto bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/type.proto

Generating Descriptor Set proto_library //third_party/protobuf:type_proto failed (Exit 1).
third_party/protobuf: warning: directory does not exist.
google/protobuf/any.proto: File not found.
google/protobuf/source_context.proto: File not found.
third_party/protobuf/google/protobuf/type.proto: Import "google/protobuf/any.proto" was not found or had errors.
third_party/protobuf/google/protobuf/type.proto: Import "google/protobuf/source_context.proto" was not found or had errors.
third_party/protobuf/google/protobuf/type.proto:57:3: "SourceContext" is not defined.
third_party/protobuf/google/protobuf/type.proto:151:3: "SourceContext" is not defined.
third_party/protobuf/google/protobuf/type.proto:178:3: "Any" is not defined.

I think the -Ithird_party/protobuf/google/protobuf/type.proto etc should be -Igoogle/protobuf/type.proto. And --direct_dependencies also needs to strip third_party/protobuf/.

The command below works with or without --proto_path=third_party/protobuf.

bazel-out/host/bin/third_party/protobuf/protoc '--proto_path=third_party/protobuf' '--descriptor_set_out=bazel-out/k8-opt/genfiles/third_party/protobuf/type_proto-descriptor-set.proto.bin' '-Igoogle/protobuf/type.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/type.proto' '-Igoogle/protobuf/any.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/any.proto' '-Igoogle/protobuf/source_context.proto=bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/source_context.proto' --direct_dependencies google/protobuf/any.proto:google/protobuf/source_context.proto:protobuf/google/protobuf/type.proto bazel-out/k8-opt/genfiles/third_party/protobuf/google/protobuf/type.proto

[1] https://github.com/protocolbuffers/protobuf/blob/master/BUILD#L264

@iirina
Copy link
Author

iirina commented Oct 1, 2018

Changed to P3 because I'm not planning to work on this next quarter.

@aiuto aiuto transferred this issue from bazelbuild/bazel May 13, 2020
@Yannic
Copy link
Collaborator

Yannic commented May 13, 2020

A lot has changed since 2018 (e.g. the aforementioned proto_source_root has since been removed), so I'm not sure if this is still an issue.

There's also work going on to change how .proto files are compiled (e.g. bazelbuild/bazel#10939, bazelbuild/bazel#1005), which will definitely fix this (in case it isn't already fixed).

@Yannic Yannic added bug Something isn't working help wanted Extra attention is needed labels May 13, 2020
@Yannic
Copy link
Collaborator

Yannic commented Jan 15, 2021

Fixed in bazelbuild/bazel#10939

@Yannic Yannic closed this as completed Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants