-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bootstrapped bazel does not support bzlmod lock file #20501
Comments
@meteorcloudy any ideas? |
I'll take a look at this |
/cc @SalmaSamy since this is related to lockfile |
From #20535
@hvadehra I need some help from a Java expert. Initially I thought this is a problem in the bootstrap java toolchain But simply adding the relevant jars didn't fix the issue.
And from the issue descriptions, building with an existing bazel binary with the same bootstrap toolchain resolves the problem. So something is missing from the raw bootstrap bazel we compiled from javac? How does annotation processor work? |
Found a fix in #20587, somehow the target/source java version matters. |
@bazel-io fork 7.0.1 |
For the bootstrap VanillaJavaBuilder, it is important that the AutoValue plugin classes do not end up in the deploy jar. If they do, the processor class is loaded from the app classloader (instead of the processor path classloader). When this happens, AutoValueProcessor uses the app classloader to load extensions (such as auto-value-gson needed by bzlmod), instead of the processor path classloader. Unless all extensions are also correctly present in the app classloder (i.e. in the VanillaJavaBuilder deploy jar), they won't be loaded. Unfortunately, simply adding the jars to the deploy jar is insufficient, we need to also correctly merge the `META-INF/service/...` files as well, which does not happen in our bootstrap java_binary/java_library rules. So, to fix, we remove the auto value plugins from the deploy jar, and use them only to compile our sources that require them. Added a regression test for the crash. We should probably improve it so that we can actually build with the bootstapped Bazel in tests without network access. But I don't think we need block this patch release on that. Fixes bazelbuild#20501 PiperOrigin-RevId: 592266992 Change-Id: I08ac91ee74140df0c4f22ad2553a8c017b497181
For the bootstrap VanillaJavaBuilder, it is important that the AutoValue plugin classes do not end up in the deploy jar. If they do, the processor class is loaded from the app classloader (instead of the processor path classloader). When this happens, AutoValueProcessor uses the app classloader to load extensions (such as auto-value-gson needed by bzlmod), instead of the processor path classloader. Unless all extensions are also correctly present in the app classloder (i.e. in the VanillaJavaBuilder deploy jar), they won't be loaded. Unfortunately, simply adding the jars to the deploy jar is insufficient, we need to also correctly merge the `META-INF/service/...` files as well, which does not happen in our bootstrap java_binary/java_library rules. So, to fix, we remove the auto value plugins from the deploy jar, and use them only to compile our sources that require them. Added a regression test for the crash. We should probably improve it so that we can actually build with the bootstapped Bazel in tests without network access. But I don't think we need block this patch release on that. Fixes #20501 Commit 2a2def8 PiperOrigin-RevId: 592266992 Change-Id: I08ac91ee74140df0c4f22ad2553a8c017b497181 Co-authored-by: Googler <[email protected]>
This works around an issue with bootstrapping bazel from scratch, see bazelbuild/bazel#20501 Fixes NixOS#273500
Will this fix be backported to 6.x ? |
@bazel-io fork 6.5.0 |
@bazel-io fork 7.1.0 |
For the bootstrap VanillaJavaBuilder, it is important that the AutoValue plugin classes do not end up in the deploy jar. If they do, the processor class is loaded from the app classloader (instead of the processor path classloader). When this happens, AutoValueProcessor uses the app classloader to load extensions (such as auto-value-gson needed by bzlmod), instead of the processor path classloader. Unless all extensions are also correctly present in the app classloder (i.e. in the VanillaJavaBuilder deploy jar), they won't be loaded. Unfortunately, simply adding the jars to the deploy jar is insufficient, we need to also correctly merge the `META-INF/service/...` files as well, which does not happen in our bootstrap java_binary/java_library rules. So, to fix, we remove the auto value plugins from the deploy jar, and use them only to compile our sources that require them. Added a regression test for the crash. We should probably improve it so that we can actually build with the bootstapped Bazel in tests without network access. But I don't think we need block this patch release on that. Fixes bazelbuild#20501 PiperOrigin-RevId: 592266992 Change-Id: I08ac91ee74140df0c4f22ad2553a8c017b497181
For the bootstrap VanillaJavaBuilder, it is important that the AutoValue plugin classes do not end up in the deploy jar. If they do, the processor class is loaded from the app classloader (instead of the processor path classloader). When this happens, AutoValueProcessor uses the app classloader to load extensions (such as auto-value-gson needed by bzlmod), instead of the processor path classloader. Unless all extensions are also correctly present in the app classloder (i.e. in the VanillaJavaBuilder deploy jar), they won't be loaded. Unfortunately, simply adding the jars to the deploy jar is insufficient, we need to also correctly merge the `META-INF/service/...` files as well, which does not happen in our bootstrap java_binary/java_library rules. So, to fix, we remove the auto value plugins from the deploy jar, and use them only to compile our sources that require them. Added a regression test for the crash. We should probably improve it so that we can actually build with the bootstapped Bazel in tests without network access. But I don't think we need block this patch release on that. Fixes #20501 PiperOrigin-RevId: 592266992 Change-Id: I08ac91ee74140df0c4f22ad2553a8c017b497181 Co-authored-by: Googler <[email protected]>
A fix for this issue has been included in Bazel 6.5.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Description of the bug:
When bootstrapping bazel from scratch using a distribution zip archive, the resulting bazel binary's
A-server.jar
does not contain the*_GsonTypeAdapter.class
files which are needed for reading / writing theMODULE.bazel.lock
file.Which category does this issue belong to?
Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
mkdir build && cd build
unzip ~/Downloads/bazel-6.4.0-dist.zip
env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
unzip output/bazel A-server.jar
unzip -l A-server.jar | grep -F _GsonTypeAdapter.class
(this should produce some output, but does not)In a project with bzlmod enabled, trying to update the
MODULE.bazel.lock
file:When trying to run inside a project with a valid lock file, bazel crashes:
Which operating system are you running Bazel on?
Ubuntu Linux
What is the output of
bazel info release
?n/a
If
bazel info release
returnsdevelopment 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?
Previously: #19672
Any other information, logs, or outputs that you want to share?
Contrary to when bootstrapping from scratch, building bazel with bazel works:
The text was updated successfully, but these errors were encountered: