bazelbuild / bazel-central-registry

The central registry of Bazel modules for the Bzlmod external dependency system.
https://registry.bazel.build
Apache License 2.0
244 stars 286 forks source link

wanted: com_google_protobuf #320

Closed alexeagle closed 1 month ago

alexeagle commented 1 year ago

Module location

https://github.com/protocolbuffers/protobuf

Link to bzlmod issue in the module's repository

No response

Any other context to provide?

@yannic says this is the next step to unblocking rules_proto usage in bzlmod.

Fund our work

comius commented 1 year ago

Actually I'm working on this. What's missing is rules_kotlin.

meteorcloudy commented 1 year ago

@comius Do we also have someone from the protobuf team looking into supporting Bzlmod?

Clement-Jean commented 1 year ago

I'm actually also working on this but I'm facing the following error:

ERROR: error loading package 'java/kotlin': at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/rules_jvm_external.4.5/kt_defs.bzl:19:6: at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/rules_jvm_external.4.5/private/rules/kt_jvm_export.bzl:1:6: at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/rules_jvm_external.4.5.non_module_deps.io_bazel_rules_kotlin/kotlin/jvm.bzl:9:5: at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/rules_jvm_external.4.5.non_module_deps.io_bazel_rules_kotlin/kotlin/internal/opts.bzl:22:5: Unable to find package for @io_bazel_rules_kotlin_configured//jvm:opts.bzl: The repository '@io_bazel_rules_kotlin_configured' could not be resolved: Repository '@io_bazel_rules_kotlin_configured' is not visible from repository '@rules_jvm_external.4.5.non_module_deps.io_bazel_rules_kotlin'.

I tried to add the following in my WORKSPACE.bzlmod:

rules_kotlin_version = "1.6.0"
rules_kotlin_sha = "a57591404423a52bd6b18ebba7979e8cd2243534736c5c94d35c89718ea38f94"
http_archive(
    name = "io_bazel_rules_kotlin",
    urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v%s/rules_kotlin_release.tgz" % rules_kotlin_version],
    sha256 = rules_kotlin_sha,
)

load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories()

load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()

but so far it doesn't work.

That seems to be related to https://github.com/bazelbuild/rules_kotlin/issues/597 and this https://github.com/bazelbuild/rules_kotlin/issues/602 but I'm not sure right now about how to solve this. If anyone has any idea, i would be interested.

meteorcloudy commented 1 year ago

rules_jvm_external.4.5

It looks like you are using an old version of Bazel, can you try again with the latest 6.0 rc? If it still doesn't work, please try to file an issue to https://github.com/bazelbuild/rules_jvm_external and provide a reproducible case.

Clement-Jean commented 1 year ago

@meteorcloudy 4.5 seems to be the version available on: Bazel Central Register and on Github, isn't it ?

Anyway, I moved to bazelisk and version 6.0.0rc4 and I have another error:

ERROR: Traceback (most recent call last):
    File "/Users/clement/Git/protobuf/WORKSPACE.bzlmod", line 12, column 20, in <toplevel>
        kotlin_repositories()
    File "/private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/io_bazel_rules_kotlin/src/main/starlark/core/repositories/initialize.bzl", line 96, column 21, in kotlin_repositories
        rules_repository(
Error in repository_rule: invalid user-provided repo name '': valid names may contain only A-Z, a-z, 0-9, '-', '_', '.', and must start with a letter
ERROR: Error computing the main repository mapping: at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/io_bazel_rules_kotlin/kotlin/core.bzl:2:5: at /private/var/tmp/_bazel_clement/5892ceef4629d9b2aad305f593ba52a0/external/io_bazel_rules_kotlin/kotlin/internal/opts.bzl:22:5: Encountered error while reading extension file 'jvm/opts.bzl': no such package '@io_bazel_rules_kotlin_configured//jvm': error loading package 'external': Could not load //external package

I opened an issue on the rules_kotlin repository (issue)

meteorcloudy commented 1 year ago

4.5 seems to be the version available on: Bazel Central Register and on Github, isn't it ?

Yes, that's the latest rules_jvm_external version. You'll also need to the latest bazel version ;)

With Bzlmod, we have stricter repository name validation, probably some repo name needs to be fixed in rules_kotlin.

meteorcloudy commented 1 year ago

But can you remove the rules_kotlin dependencies in WORKSPACE.bzlmod, I don't see why fixing protobuf needs rules_kotlin to work.

Clement-Jean commented 1 year ago

When I remove the rules_kotlin, I have this error:

ERROR: Skipping '//...': error loading package under directory '': error loading package 'java/kotlin-lite': Unable to find package for @[unknown repo 'io_bazel_rules_kotlin' requested from @]//kotlin:jvm.bzl: The repository '@[unknown repo 'io_bazel_rules_kotlin' requested from @]' could not be resolved: No repository visible as '@io_bazel_rules_kotlin' from main repository.
WARNING: Target pattern parsing failed.
ERROR: error loading package under directory '': error loading package 'java/kotlin-lite': Unable to find package for @[unknown repo 'io_bazel_rules_kotlin' requested from @]//kotlin:jvm.bzl: The repository '@[unknown repo 'io_bazel_rules_kotlin' requested from @]' could not be resolved: No repository visible as '@io_bazel_rules_kotlin' from main repository.

we actually need rules_kotlin because in the java/kotlin and kotlin-lite directory we use the kt_jvm_library rule (here).

meteorcloudy commented 1 year ago

I see, then this probably has to wait for https://github.com/bazelbuild/rules_kotlin/pull/878

comius commented 1 year ago

I added more info on what needs to happen on rules_kotlin in https://github.com/bazelbuild/rules_kotlin/issues/660

Do we also have someone from the protobuf team looking into supporting Bzlmod?

Not anybody in particular, but I've heard they are interested.

meteorcloudy commented 1 year ago

Looks like the protobuf team currently doesn't have bandwidth for https://github.com/protocolbuffers/protobuf/issues/12184

Clement-Jean commented 1 year ago

@meteorcloudy Still on this. I have the following error now:

No repository visible as '@io_bazel_rules_kotlin_configured' from repository '@rules_jvm_external~5.2~non_module_deps~io_bazel_rules_kotlin'.

We seem to have a problem with either koltin or jvm external rule.

If anyone wants to check here is the repo: https://github.com/Clement-Jean/protobuf/tree/bzlmod

I'm able to run the following commands:

bazel build --enable_bzlmod //:protobuf
bazel build --enable_bzlmod //:protoc
bazel build --enable_bzlmod //:protobuf_lite
bazel build --enable_bzlmod //:protobuf_python

but not:

bazel test --enable_bzlmod //java:tests
Clement-Jean commented 1 year ago

Turns out rules_python and rules_jvm_external are not compatible yet. Protobuf relies on rules_python@0.14.0 which is broken in the registry and rules_jvm_external@5.2 gives the kotlin error shown in the previous comment.

However, I have temporarily added them into the WORKSPACE.bzlmod. It seems that it is working, how could I test this further?

malt3 commented 1 year ago

Relevant upstream issue: https://github.com/protocolbuffers/protobuf/issues/13618

It looks like things are beginning to move! Thank you to everyone involved ❤️

chrislovecnm commented 10 months ago

Anyone have a status?

bgdnvk commented 9 months ago

bump ive been running into issues with gazelle here by using bazel module

Wyverald commented 1 month ago

protobuf is now maintained by the protobuf team from Google.