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

same module_extension name in different bzl files could not be resolved while using bzlmod in bazel 6.3.1 #19155

Closed
xiemotongye opened this issue Aug 3, 2023 · 5 comments
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@xiemotongye
Copy link

xiemotongye commented Aug 3, 2023

Description of the bug:

We're using bzlmod.
This is a part of MODULE.bazel, which works fine in bazel 6.2.1.

a_ext = use_extension("//path/to/A:A.bzl", "my_ext")
use_repo(a_ext, "abc")
b_ext = use_extension("//path/to/B:B.bzl", "my_ext")
use_repo(b_ext, "xyz")

When I updated bazel to 6.3.1, there was an error in analysis phase.

ERROR: /my/workspace/library_path/BUILD:4:13: no such package '@_main~my_ext~2~xyz//':
The repository '@_main~my_ext~2~xyz' could not be resolved:
Repository '@_main~my_ext~2~xyz' is not defined and referenced by '//library_path:library_name'
ERROR: Analysis of target '//my_path:my_target' failed; build aborted:

It seems that in bazel 6.2.1, if there is a same module_extension name in different bzl files, the second one will be named as @_main~my_ext2~xyz in external directory. But in bazel 6.3.1, it seems that bazel is tring to find a module named as @_main~my_ext~2~xyz (adds a ~ after ext) which doesn't actually exist.

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.

No response

Which operating system are you running Bazel on?

macOS 13.4.1

What is the output of bazel info release?

release 6.3.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 master; 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

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

No response

@Pavank1992 Pavank1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Aug 3, 2023
@fmeum
Copy link
Collaborator

fmeum commented Aug 3, 2023

Can confirm that this is a bug. The two extensions are assigned the prefixes _main~my_ext~ and _main~my_ext~2~ now, which is bad since the former is a prefix of the latter.

I am working on a fix.

CC @Wyverald

@fmeum
Copy link
Collaborator

fmeum commented Aug 3, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 3, 2023
@iancha1992
Copy link
Member

@bazel-io fork 6.4.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 3, 2023
@fmeum
Copy link
Collaborator

fmeum commented Aug 3, 2023

@iancha1992 This is a regression from Bazel 6.2.0, so unfortunately we may need a 6.3.2 release to cherry-pick this into.

@iancha1992
Copy link
Member

cc: @bazelbuild/triage

@Wyverald Wyverald added P1 I'll work on this now. (Assignee required) area-Bzlmod Bzlmod-specific PRs, issues, and feature requests and removed untriaged labels Aug 3, 2023
iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Aug 3, 2023
Fixes errors such as the following when a module provides two extensions that share a name:

```
ERROR: /my/workspace/library_path/BUILD:4:13: no such package '@_main~my_ext~2~xyz//':
The repository '@_main~my_ext~2~xyz' could not be resolved:
Repository '@_main~my_ext~2~xyz' is not defined and referenced by '//library_path:library_name'
ERROR: Analysis of target '//my_path:my_target' failed; build aborted:
```

This was a consequence of the extension unique names followed by `~` being

```
_main~my_ext~2~
_main~my_ext~
```

since 19a9710. Before, they were of the following form, which was prefix-free:

```
_main~my_ext2~
_main~my_ext~
```

Fixes bazelbuild#19155

Closes bazelbuild#19156.

PiperOrigin-RevId: 553567725
Change-Id: I98650663fea3bfee77752a06a99132e507d91aef
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Aug 3, 2023
Fixes errors such as the following when a module provides two extensions that share a name:

```
ERROR: /my/workspace/library_path/BUILD:4:13: no such package '@_main~my_ext~2~xyz//':
The repository '@_main~my_ext~2~xyz' could not be resolved:
Repository '@_main~my_ext~2~xyz' is not defined and referenced by '//library_path:library_name'
ERROR: Analysis of target '//my_path:my_target' failed; build aborted:
```

This was a consequence of the extension unique names followed by `~` being

```
_main~my_ext~2~
_main~my_ext~
```

since 19a9710. Before, they were of the following form, which was prefix-free:

```
_main~my_ext2~
_main~my_ext~
```

Fixes bazelbuild#19155

Closes bazelbuild#19156.

PiperOrigin-RevId: 553567725
Change-Id: I98650663fea3bfee77752a06a99132e507d91aef
iancha1992 added a commit that referenced this issue Aug 3, 2023
…19164)

Fixes errors such as the following when a module provides two extensions that share a name:

```
ERROR: /my/workspace/library_path/BUILD:4:13: no such package '@_main~my_ext~2~xyz//':
The repository '@_main~my_ext~2~xyz' could not be resolved:
Repository '@_main~my_ext~2~xyz' is not defined and referenced by '//library_path:library_name'
ERROR: Analysis of target '//my_path:my_target' failed; build aborted:
```

This was a consequence of the extension unique names followed by `~` being

```
_main~my_ext~2~
_main~my_ext~
```

since 19a9710. Before, they were of the following form, which was prefix-free:

```
_main~my_ext2~
_main~my_ext~
```

Fixes #19155

Closes #19156.

PiperOrigin-RevId: 553567725
Change-Id: I98650663fea3bfee77752a06a99132e507d91aef

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Wyverald pushed a commit that referenced this issue Aug 3, 2023
…19167)

Fixes errors such as the following when a module provides two extensions that share a name:

```
ERROR: /my/workspace/library_path/BUILD:4:13: no such package '@_main~my_ext~2~xyz//':
The repository '@_main~my_ext~2~xyz' could not be resolved:
Repository '@_main~my_ext~2~xyz' is not defined and referenced by '//library_path:library_name'
ERROR: Analysis of target '//my_path:my_target' failed; build aborted:
```

This was a consequence of the extension unique names followed by `~` being

```
_main~my_ext~2~
_main~my_ext~
```

since 19a9710. Before, they were of the following form, which was prefix-free:

```
_main~my_ext2~
_main~my_ext~
```

Fixes #19155

Closes #19156.

PiperOrigin-RevId: 553567725
Change-Id: I98650663fea3bfee77752a06a99132e507d91aef

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
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 P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants