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

Fix android_extensions.bzl with Bazel 8.0.0rc1 and later #1270

Open
meteorcloudy opened this issue Oct 23, 2024 · 10 comments
Open

Fix android_extensions.bzl with Bazel 8.0.0rc1 and later #1270

meteorcloudy opened this issue Oct 23, 2024 · 10 comments

Comments

@meteorcloudy
Copy link
Contributor

Running bazel mod deps with Bazel 8.0.0rc1 or later results:

ERROR: Error loading '@@bazel_tools//tools/android:android_extensions.bzl' for module extensions, requested by https://bcr.bazel.build/modules/rules_jvm_external/6.0/MODULE.bazel:29:42: Label '@@bazel_tools//tools/android:android_extensions.bzl' is invalid because 'tools/android' is not a package; perhaps you meant to put the colon here: '@@bazel_tools//tools:android/android_extensions.bzl'?: Label '@@bazel_tools//tools/android:android_extensions.bzl' is invalid because 'tools/android' is not a package; perhaps you meant to put the colon here: '@@bazel_tools//tools:android/android_extensions.bzl'?. Type 'bazel help mod' for syntax and help.

This is due to bazelbuild/bazel@ef1a21f and probably should switch to use https://github.com/bazelbuild/rules_android/blob/e7729c61025c394fb77b220b917e15494271d7b8/MODULE.bazel#L140-L141 from rules_android

@meteorcloudy
Copy link
Contributor Author

@shs96c @jin @ahumesky

@shs96c
Copy link
Collaborator

shs96c commented Oct 23, 2024

Presumably the new rules_android will also work with Bazel 6? We'd like to continue supporting that until Bazel 9 ships

@ahumesky
Copy link
Contributor

rules_android has only been targeting bazel 7 and 8, we'll have to see what does and doesn't work with bazel 6, and what can be worked around in the rules. I can see when I pick #1215 back up

@meteorcloudy
Copy link
Contributor Author

Presumably the new rules_android will also work with Bazel 6?

Do you actually need to support Bazel 6 with Bzlmod enabled (which is not the default)?

@meteorcloudy
Copy link
Contributor Author

I was trying to fix this for rules_jvm_external but found out rules_kotlin is also broken

ERROR: Error loading '@@bazel_tools//tools/android:android_extensions.bzl' for module extensions, requested by https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel:29:42: Label '@@bazel_tools//tools/android:android_extensions.bzl' is invalid because 'tools/android' is not a package; perhaps you meant to put the colon here: '@@bazel_tools//tools:android/android_extensions.bzl'?: Label '@@bazel_tools//tools/android:android_extensions.bzl' is invalid because 'tools/android' is not a package; perhaps you meant to put the colon here: '@@bazel_tools//tools:android/android_extensions.bzl'?. Type 'bazel help mod' for syntax and help.

https://github.com/bazelbuild/rules_kotlin/blob/c93d6ae990a1d063f0a4e6fbef7447af2799f661/MODULE.bazel#L45-L47

@ahumesky @ted-xie Can we partially revert bazelbuild/bazel@ef1a21f#diff-cefcdd5baa8fc0ebdd3c850a8e698499ecebba0b1072d429743c05b1ef287d2e in Bazel 8.0.0, otherwise, older version of rules_jvm_external and rules_kotlin will just be broken with Bazel 8+

@shs96c
Copy link
Collaborator

shs96c commented Oct 25, 2024

We only support blzmod when using Bazel 7+, but we still want to support folks using Bazel 6 and workspace-based builds, and we normally try and keep rules we depend on in sync between the workspace and bzlmod builds.

@meteorcloudy
Copy link
Contributor Author

Yeah, rules_jvm_external@HEAD should probably migrate to use the latest version of rules_android. I sent bazelbuild/bazel#24094 to hopefully make bazel 8 also work with older rules_jvm_external versions.

@ahumesky
Copy link
Contributor

ahumesky commented Oct 25, 2024

rules_jvm_external@HEAD should probably migrate to use the latest version of rules_android

That's what my PR that was reverted here is about: #1215

Reapplying / unreverting that is blocked on rules_android 0.6.0, which is blocked on getting it to work with bazel 8.0, which is blocked on protobuf issues (include bazelbuild/bazel#23908 that you reference in bazelbuild/bazel#24094)

I was trying to fix this for rules_jvm_external but found out rules_kotlin is also broken

rules_kotlin has a pending PR (bazelbuild/rules_kotlin#1205) to update to use rules_android, but they're blocked on rules_jvm_external updating to rules_android (which is blocked as above)

rules_kotlin has a similar PR to remove dependending on @bazel_tools (bazelbuild/rules_kotlin#1228)

@ahumesky
Copy link
Contributor

hopefully make bazel 8 also work with older rules_jvm_external versions

How far back do we need to go? Older versions of rules_jvm_external e.g. rely on natively-defined aar_import, which is deleted in bazel 8

@jin
Copy link
Collaborator

jin commented Oct 28, 2024

Sorry if I've missed a crucial point, but I think it'll help discussions if we can come up with an actual compatibility matrix here. e.g. it would be really good if RJE can retain N-2 LTS versions, but to what degree is this requirement a hard blocker for the other rulesets (android, kotlin, java) to make progress?

meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Oct 28, 2024
This PR address two problems:
- Partially rolledback bazelbuild@ef1a21f to restore android tools extension to avoid breaking older rules_jvm_external and rules_kotlin versions: bazel-contrib/rules_jvm_external#1270
- Add protobuf in MODULE.tools to ensure a Bazel 8 compatible version gets selected. (related bazelbuild#23908)

Closes bazelbuild#24094.

PiperOrigin-RevId: 690625240
Change-Id: I47e9ab7cab9bbfd09e455fb72d3d99d3e73f1f90
copybara-service bot pushed a commit to bazelbuild/bazel that referenced this issue Oct 28, 2024
This PR address two problems:
- Partially rolledback ef1a21f to restore android tools extension to avoid breaking older rules_jvm_external and rules_kotlin versions: bazel-contrib/rules_jvm_external#1270
- Add protobuf in MODULE.tools to ensure a Bazel 8 compatible version gets selected. (related #23908)

Closes #24094.

PiperOrigin-RevId: 690651136
Change-Id: I47e9ab7cab9bbfd09e455fb72d3d99d3e73f1f90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants