bazel-central-registry icon indicating copy to clipboard operation
bazel-central-registry copied to clipboard

wanted: com_google_protobuf

Open alexeagle opened this issue 2 years ago • 16 comments

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

  • [ ] Sponsor our community's open source work by donating a feature bounty

alexeagle avatar Dec 12 '22 15:12 alexeagle

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

comius avatar Dec 12 '22 15:12 comius

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

meteorcloudy avatar Dec 12 '22 16:12 meteorcloudy

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.

Clement-Jean avatar Dec 13 '22 01:12 Clement-Jean

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.

meteorcloudy avatar Dec 13 '22 09:12 meteorcloudy

@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)

Clement-Jean avatar Dec 14 '22 02:12 Clement-Jean

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 avatar Dec 14 '22 09:12 meteorcloudy

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

meteorcloudy avatar Dec 14 '22 09:12 meteorcloudy

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).

Clement-Jean avatar Dec 14 '22 10:12 Clement-Jean

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

meteorcloudy avatar Dec 14 '22 10:12 meteorcloudy

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.

comius avatar Dec 20 '22 13:12 comius

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

meteorcloudy avatar May 16 '23 17:05 meteorcloudy

@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 avatar May 22 '23 08:05 Clement-Jean

Turns out rules_python and rules_jvm_external are not compatible yet. Protobuf relies on [email protected] which is broken in the registry and [email protected] 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?

Clement-Jean avatar May 23 '23 02:05 Clement-Jean

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

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

malt3 avatar Aug 31 '23 07:08 malt3

Anyone have a status?

chrislovecnm avatar Nov 05 '23 16:11 chrislovecnm

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

bgdnvk avatar Dec 06 '23 12:12 bgdnvk

protobuf is now maintained by the protobuf team from Google.

Wyverald avatar Jul 23 '24 23:07 Wyverald