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

bazel mod show_repo <canonical repo name> doesn't work for module extension generated repos. #21621

Closed
meteorcloudy opened this issue Mar 8, 2024 · 14 comments
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) type: bug

Comments

@meteorcloudy
Copy link
Member

meteorcloudy commented Mar 8, 2024

Description of the bug:

For a module extension generated repo, the following works:

bazel mod show_repo <apparent repo name> --base_module=<module name>

However, it'll be nice to also also have

bazel mod show_repo <canonical repo name>

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.

In the Bazel repo, with Bazel 7.1.0rc2

bazel mod show_repo @@rules_jvm_external~~maven~maven

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NullPointerException: Cannot invoke "com.google.devtools.build.lib.cmdline.RepositoryName.equals(Object)" because the return value of "com.google.common.collect.ImmutableMap.get(Object)" is null
	at com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg$CanonicalRepoName.lambda$resolveToRepoNames$1(ModuleArg.java:340)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at com.google.common.collect.CollectSpliterators$1WithCharacteristics.lambda$tryAdvance$0(CollectSpliterators.java:67)
	at java.base/java.util.stream.Streams$RangeIntSpliterator.tryAdvance(Unknown Source)
	at com.google.common.collect.CollectSpliterators$1WithCharacteristics.tryAdvance(CollectSpliterators.java:67)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.findAny(Unknown Source)
	at com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg$CanonicalRepoName.resolveToRepoNames(ModuleArg.java:341)
	at com.google.devtools.build.lib.bazel.commands.ModCommand.execInternal(ModCommand.java:340)
	at com.google.devtools.build.lib.bazel.commands.ModCommand.exec(ModCommand.java:138)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:664)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:644)
	at io.grpc.Context$1.run(Context.java:566)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

7.1.0rc2

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

@meteorcloudy meteorcloudy added type: bug P2 We'll consider working on this in future. (Assignee optional) area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Mar 8, 2024
@Wyverald
Copy link
Member

Wyverald commented Mar 8, 2024

ah, I think this is as simple as removing that if check. if a nonexistent canonical repo name is passed in, we could just let it fail a bit later instead.

@meteorcloudy
Copy link
Member Author

meteorcloudy commented Mar 11, 2024

@Wyverald I don't quite understand, I didn't see anywhere in the code that is checking the canonical repo name generated by module extension? (@@rules_jvm_external~~maven~maven does exist, the expected result is to output the repo spec.)

@Wyverald
Copy link
Member

I meant removing the check at https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModuleArg.java;drc=a54a393d209ab9c8cf5e80b2a0ef092196c17df3;l=339, so we don't check that the canonical repo name is from a module. We can simply not check anything at all and let it fail later if the repo doesn't actually exist.

@fmeum
Copy link
Collaborator

fmeum commented Mar 14, 2024

@bazel-io fork 7.1.1

bazel-io pushed a commit to bazel-io/bazel that referenced this issue Mar 14, 2024
Previously we enforced that the canonical repo name had to correspond to a module (i.e. not an extension-generated repo). This makes no sense, so this change simple deletes that enforcement.

To compensate for the lack of checks whether the repo exists at all, we add an additional check after requesting the BzlmodRepoRuleValues that all requested repos must exist.

Fixes bazelbuild#21621

PiperOrigin-RevId: 615733963
Change-Id: Icf706b36f0e8d3c775bc26528948e5102910d4a0
github-merge-queue bot pushed a commit that referenced this issue Mar 14, 2024
…_repo` (#21694)

Previously we enforced that the canonical repo name had to correspond to
a module (i.e. not an extension-generated repo). This makes no sense, so
this change simple deletes that enforcement.

To compensate for the lack of checks whether the repo exists at all, we
add an additional check after requesting the BzlmodRepoRuleValues that
all requested repos must exist.

Fixes #21621

Commit
5c2b37e

PiperOrigin-RevId: 615733963
Change-Id: Icf706b36f0e8d3c775bc26528948e5102910d4a0

Co-authored-by: Googler <[email protected]>
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.1.1 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.1.1rc1. Thanks!

@meteorcloudy
Copy link
Member Author

FYI @lberki

@lberki
Copy link
Contributor

lberki commented Mar 18, 2024

Thanks! (any news about reporting something useful when there are modules/repositories that are in error but the one I am interested in is not?)

@meteorcloudy
Copy link
Member Author

I believe a successful resolution result is still a requirement for the bazel mod command? @Wyverald can confirm that.

@lberki
Copy link
Contributor

lberki commented Mar 18, 2024

That's why I think too, although I certainly hoped that that one somehow got fixed in the meantime

@wingsofovnia
Copy link

I am still having the issue on 7.1.1:

> bazel --version                                                   
bazel 7.1.1

> bazel mod show_extension @@rules_oci~6.0.5//oci:extensions.bzl%oci
Starting local Bazel server and connecting to it...
 checking cached actions
    Fetching https://bcr.bazel.build/modules/rules_python_gazelle_plugin/0.31.0/source.json
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NullPointerException: Cannot invoke "com.google.devtools.build.lib.cmdline.RepositoryName.equals(Object)" because the return value of "com.google.common.collect.ImmutableMap.get(Object)" is null
        at com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg$CanonicalRepoName.lambda$resolveToModuleKeys$0(ModuleArg.java:308)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
        at com.google.common.collect.CollectSpliterators$1WithCharacteristics.lambda$tryAdvance$0(CollectSpliterators.java:67)
        at java.base/java.util.stream.Streams$RangeIntSpliterator.tryAdvance(Unknown Source)
        at com.google.common.collect.CollectSpliterators$1WithCharacteristics.tryAdvance(CollectSpliterators.java:67)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.findAny(Unknown Source)
        at com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg$CanonicalRepoName.resolveToModuleKeys(ModuleArg.java:309)
        at com.google.devtools.build.lib.bazel.bzlmod.modcommand.ExtensionArg.resolveToExtensionId(ExtensionArg.java:66)
        at com.google.devtools.build.lib.bazel.commands.ModCommand.execInternal(ModCommand.java:365)
        at com.google.devtools.build.lib.bazel.commands.ModCommand.exec(ModCommand.java:139)
        at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:664)
        at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244)
        at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
        at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:644)
        at io.grpc.Context$1.run(Context.java:566)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

@meteorcloudy
Copy link
Member Author

@wingsofovnia Thanks for reporting, we'll fix it.

@meteorcloudy
Copy link
Member Author

@bazel-io fork 7.2.0

iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Apr 16, 2024
Fixes bazelbuild#21621 (comment)

PiperOrigin-RevId: 625286656
Change-Id: Ibc5d153af96912de39b146e50f081030d1da7257
github-merge-queue bot pushed a commit that referenced this issue Apr 17, 2024
)

Fixes
#21621 (comment)

PiperOrigin-RevId: 625286656
Change-Id: Ibc5d153af96912de39b146e50f081030d1da7257

Commit
2d54af1

Co-authored-by: Googler <[email protected]>
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
Fixes bazelbuild#21621 (comment)

PiperOrigin-RevId: 625286656
Change-Id: Ibc5d153af96912de39b146e50f081030d1da7257
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.2.0 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.2.0rc1. Thanks!

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 P2 We'll consider working on this in future. (Assignee optional) type: bug
Projects
None yet
Development

No branches or pull requests

7 participants