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

proto_library's import_prefix does not work across repository boundaries #8030

Closed
RNabel opened this issue Apr 14, 2019 · 2 comments
Closed
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Server Issues for serverside rules included with Bazel type: bug

Comments

@RNabel
Copy link
Contributor

RNabel commented Apr 14, 2019

Description of the problem / feature request:

import_prefix does not set the prefix correctly when the proto_library target lives in an external dependency.

Feature requests: what underlying problem are you trying to solve with this feature?

The import_prefix should work across repo boundaries.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

(Skip to Repro case below for a zip containing a testable example of the reported behaviour)

Create a proto_library with import_prefix and reference it from a different workspace. If the depended-on repository has name dependency_a and the depended-on proto_library target uses import_prefix = "prefix_a", the expected import path is in a .proto file is:

import "prefix_a/test.proto";

but the actual path is:

import "prefix_a/external/dependency_a/test.proto";

Repro case

Please download this repro.zip, which illustrates this behaviour using a local_repository.

$ tree
.
├── BUILD
├── WORKSPACE
├── local_repo
│   ├── BUILD
│   ├── WORKSPACE
│   └── imported.proto
└── test.proto

Build the repro target: bazel build :test_proto
The file test.proto contains both the expected, non-functional import path, and the actual import path.

What operating system are you running Bazel on?

macOS 10.14

What's the output of bazel info release?

Tested on both 0.22 and 0.24.1

Have you found anything relevant by searching the web?

Related error: proto_source_root not working across multiple workspaces #4665

@aiuto aiuto added team-Bazel General Bazel product/strategy issues untriaged labels Apr 15, 2019
@aiuto aiuto added team-Rules-Server Issues for serverside rules included with Bazel and removed team-Bazel General Bazel product/strategy issues labels Jun 12, 2019
@aiuto
Copy link
Contributor

aiuto commented Jun 12, 2019

My bad on the mis-categorization

@hlopko
Copy link
Member

hlopko commented Jun 21, 2019

Hi Robin, could you pls check that #8683 fixes your problem?

@hlopko hlopko added P2 We'll consider working on this in future. (Assignee optional) type: bug and removed untriaged labels Jun 21, 2019
@hlopko hlopko self-assigned this Jun 21, 2019
siberex pushed a commit to siberex/bazel that referenced this issue Jul 4, 2019
Before this PR, when strip_import_prefix was not specified, and the proto target
was declared in an external repository, Bazel generated import path that leaked
`external/<repository_name>` path fragment. That path fragment is an
implementation detail of Bazel's execroot layout and should not be used in proto
source files.

This PR adds a correct path fragment to the import paths. It also introduces an incompatible flag `--incompatible_do_not_emit_buggy_external_repo_import` that removes the incorrect import path from Bazel.

Fixes bazelbuild#8030.

Incompatible change: bazelbuild#8711.

Closes bazelbuild#8683.

PiperOrigin-RevId: 255606742
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
Before this PR, when strip_import_prefix was not specified, and the proto target
was declared in an external repository, Bazel generated import path that leaked
`external/<repository_name>` path fragment. That path fragment is an
implementation detail of Bazel's execroot layout and should not be used in proto
source files.

This PR adds a correct path fragment to the import paths. It also introduces an incompatible flag `--incompatible_do_not_emit_buggy_external_repo_import` that removes the incorrect import path from Bazel.

Fixes bazelbuild#8030.

Incompatible change: bazelbuild#8711.

Closes bazelbuild#8683.

PiperOrigin-RevId: 255606742
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Server Issues for serverside rules included with Bazel type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants