After further debugging, I wonder if the cause might be the fact that this
line in the protobuf MODULE.bazel
<https://github.com/protocolbuffers/protobuf/blob/main/MODULE.bazel#L95>file
has dev_dependency = True
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven",
dev_dependency = True)
According to this <https://bazel.build/rules/lib/globals/module#use_repo>,
dev_dependency
= True causes Bazel to ignore the dependency when the Module is not the
root module.
I attempted to clone the protobuf repo and tried to build java/util:util
with the flag --ignore_dev_dependency and got the following error:
*ERROR: *no such package '@@[unknown repo 'protobuf_maven' requested from
@@]//': The repository '@@[unknown repo 'protobuf_maven' requested from
@@]' could not be resolved: No repository visible as '@protobuf_maven' from
main repository
*ERROR: */Users/lothaireruellan/Projects/protobuf/java/util/BUILD.bazel:9:13:
no such package '@@[unknown repo 'protobuf_maven' requested from @@]//':
The repository '@@[unknown repo 'protobuf_maven' requested from @@]' could
not be resolved: No repository visible as '@protobuf_maven' from main
repository and referenced by '//java/util:util'
*ERROR: *Analysis of target '//java/util:util' failed; build aborted:
Analysis failed
In my situation, the protobuf Module is not the root module of my project,
hence I wonder if protobuf_maven is getting pruned by Bazel when building
my project.
On Monday, March 3, 2025 at 1:55:18 AM UTC-5 Lothaire Ruellan wrote:
> Hi,
>
> I have a Bazel module that depends on protobuf and which used to build
> successfully both locally and on Google Cloud Build.
>
> Today, Cloud Build started failing with the following error:
>
> INFO: Repository rules_jvm_external++maven+protobuf_maven instantiated at:
> <builtin>: in <toplevel>
> Repository rule coursier_fetch defined at:
> /builder/home/.cache/bazel/_bazel_ubuntu/eab0d61a99b6696edb3d2aff87b585e8/external/rules_jvm_external+/private/rules/coursier.bzl:1447:33:
>
> in <toplevel>
> ERROR:
> /builder/home/.cache/bazel/_bazel_ubuntu/eab0d61a99b6696edb3d2aff87b585e8/external/rules_jvm_external+/private/rules/coursier.bzl:937:13:
>
> An error occurred during the fetch of repository
> 'rules_jvm_external++maven+protobuf_maven':
> Traceback (most recent call last):
> File
> "/builder/home/.cache/bazel/_bazel_ubuntu/eab0d61a99b6696edb3d2aff87b585e8/external/rules_jvm_external+/private/rules/coursier.bzl",
>
> line 1051, column 38, in _coursier_fetch_impl
> dep_tree = make_coursier_dep_tree(
> File
> "/builder/home/.cache/bazel/_bazel_ubuntu/eab0d61a99b6696edb3d2aff87b585e8/external/rules_jvm_external+/private/rules/coursier.bzl",
>
> line 937, column 13, in make_coursier_dep_tree
> fail("Error while fetching artifact with coursier: " + exec_result.stderr)
> Error in fail: Error while fetching artifact with coursier: Error: Could
> not find or load main class
> @.builder.home..cache.bazel._bazel_ubuntu.eab0d61a99b6696edb3d2aff87b585e8.external.rules_jvm_external++maven+protobuf_maven.java_argsfile
> ERROR: no such package '@@rules_jvm_external++maven+protobuf_maven//':
> Error while fetching artifact with coursier: Error: Could not find or load
> main class
> @.builder.home..cache.bazel._bazel_ubuntu.eab0d61a99b6696edb3d2aff87b585e8.external.rules_jvm_external++maven+protobuf_maven.java_argsfile
> ERROR:
> /builder/home/.cache/bazel/_bazel_ubuntu/eab0d61a99b6696edb3d2aff87b585e8/external/protobuf+/java/util/BUILD.bazel:8:13:
>
> @@protobuf+//java/util:util depends on
> @@rules_jvm_external++maven+protobuf_maven//:com_google_j2objc_j2objc_annotations
>
> in repository @@rules_jvm_external++maven+protobuf_maven which failed to
> fetch. no such package '@@rules_jvm_external++maven+protobuf_maven//':
> Error while fetching artifact with coursier: Error: Could not find or load
> main class
> @.builder.home..cache.bazel._bazel_ubuntu.eab0d61a99b6696edb3d2aff87b585e8.external.rules_jvm_external++maven+protobuf_maven.java_argsfile
>
> I'm still able to build this module locally.
> I've tried to debug this error but I'm stuck. Any idea what might be
> causing this or how to fix it?
>
> Lothaire
>
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/protobuf/15bbb504-8144-4535-895e-5d173a9540a8n%40googlegroups.com.