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

duplicate repos between WORKSPACE and MODULE when using repo_name mapping #21818

Open
jbedard opened this issue Mar 26, 2024 · 5 comments
Open
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-user-response Awaiting a response from the author P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@jbedard
Copy link

jbedard commented Mar 26, 2024

Description of the bug:

When using bzlmod and a bazel_dep(repo_name) that dependency does not shadow WORKSPACE repositories of the same name.

For example, usually the protobuf module is named com_google_protobuf in typical workspace setups. The bzlmod name is protobuf but needs to be aliased to com_google_protobuf to align with typical naming. When this is done the bazel_dep(repo_name = "com_google_protobuf") is not shadowing the http_archive(name = "com_google_protobuf").

Which category does this issue belong to?

No response

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

bazel build //... in https://github.com/jbedard/bzlmod-repo_name-dupe

This shows the bazel_dep(name = "aspect_bazel_lib", repo_name) not shadowing the transitive aspect_bazel_lib loaded from the WORKSPACE rules_js_dependencies().

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

7.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@sgowroji sgowroji added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Mar 27, 2024
@alexeagle
Copy link
Contributor

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Apr 16, 2024
@meteorcloudy meteorcloudy self-assigned this Apr 16, 2024
@Wyverald
Copy link
Member

Sorry for the long delay. In the README of your repro, you said:

This repository shows bazel_dep(name = "aspect_bazel_lib", version = "2.3.0", repo_name = "foobar") in MODULE.bazel NOT shadowing the aspect_bazel_lib loaded by rules_js via rules_js_dependencies() in WORKSPACE.

But that's expected behavior. This dep would shadow a repo called foobar loaded in WORKSPACE. If you remove the repo_name="foobar" part, it would correctly shadow anything called aspect_bazel_lib.

@jbedard
Copy link
Author

jbedard commented Apr 17, 2024

But that's expected behavior. This dep would shadow a repo called foobar loaded in WORKSPACE

That also does not work. See the protobuf example in the issue description.

@Wyverald
Copy link
Member

But that's expected behavior. This dep would shadow a repo called foobar loaded in WORKSPACE

That also does not work. See the protobuf example in the issue description.

That would be unexpected. Do you have a repro for that?

@jbedard
Copy link
Author

jbedard commented Apr 18, 2024

There are various cases where shadowing is required. When legacy non-bzlmod loads a repository we need a reliable way to ensure that it can be shadowed by bzlmod modules.

  1. http_archive(name) may need to be shadowed by bazel_dep(name), this seems to work
  2. http_archive(name) may need to be shadowed by bazel_dep(repo_name), this seems broken
  3. http_archive(name) may need to be shadowed by bazel_dep(name) while I want to use repo_name for my local repo

The first seems to work, the protobuf issue is 2, and I guess my repo showed 3.

I'll try adding a case for 2 in my repo but I'm having trouble creating a simple one, I've only had the issue in fairly large repos.

@Wyverald Wyverald added the awaiting-user-response Awaiting a response from the author label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-user-response Awaiting a response from the author P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

7 participants