bazel-contrib / rules_jvm_external

Bazel rules to resolve, fetch and export Maven artifacts
Apache License 2.0
332 stars 254 forks source link

Error repinning with maven resolver #1205

Open peakschris opened 2 months ago

peakschris commented 2 months ago

I'm seeing this issue with rules_jvm_external 6.1 and also 6.2:

set REPIN=1
bazel run @maven//:pin
ERROR: Traceback (most recent call last):
        File "D:/udu/b/qpawu7hm/external/rules_jvm_external~/private/extensions/maven.bzl", line 438, column 45, in _maven_impl
                unpinned_maven_pin_command_alias(
Error in repository_rule: no repository visible as '@maven' to the repository '@@rules_jvm_external~', but referenced by label '@maven//:pin' in attribute 'alias' of unpinned_maven_pin_command_alias 'unpinned_maven'. Is the module 'rules_jvm_external' missing a bazel_dep or use_repo(..., "maven")?

my MODULE.bazel is:

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
    name = "maven",
    artifacts = [
        <snip>
    ],
    repositories = [
         "https://artifactory.internal/maven",
    ],
    resolver = "maven",
    fail_on_missing_checksum = False,
    strict_visibility = True,
    generate_compat_repositories = False,
    fail_if_repin_required = True,
    lock_file = "//src/path/to:maven_install.json",
    # use the exact versions for any artifacts explicltly specified above
    version_conflict_policy = "pinned",
    repin_instructions = "bb maven repin",
    additional_netrc_lines = ["credentials"],
)

use_repo(maven, "maven")
SanjayVas commented 1 month ago

This error happens even when just trying to update the Bazel lockfile (MODULE.bazel.lock) via bazel mod deps --lockfile_mode=update and not using pinning. More specifically, I get the above error when using Bazel 7.3.1. If I use 7.1.0, I get the following error instead:

ERROR: module extension "maven" from "@@rules_jvm_external~//:extensions.bzl" does not generate repository "maven", yet it is imported as "maven"
SanjayVas commented 1 month ago

This appears to be the issue: https://github.com/bazelbuild/rules_jvm_external/blob/61e8eda72f8cafcecf8b2aef0ef62dd58bfa953d/private/extensions/maven.bzl#L436-L441

I was able to get it working by patching that out locally.