Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Build error: no such package '@@rules_jvm_external++maven+protobuf_maven//'

69 views
Skip to first unread message

Lothaire Ruellan

unread,
Mar 3, 2025, 1:55:18 AMMar 3
to Protocol Buffers
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

Lothaire Ruellan

unread,
Mar 3, 2025, 8:50:48 AMMar 3
to Protocol Buffers
After further debugging, I wonder if the cause might be the fact that this line in the protobuf MODULE.bazel file has dev_dependency = True

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)

According to this, 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.
Reply all
Reply to author
Forward
0 new messages