rules_jvm_external
                                
                                
                                
                                    rules_jvm_external copied to clipboard
                            
                            
                            
                        Random timeout error in maven_install()
I'm getting random timeout while fetching Maven artifacts in Bazel run. Sometimes it can run successfully within few seconds. I checked my network it is stable with 800Mbps download speed.
ERROR: no such package '@maven//': Error while fetching artifact with coursier: Timed out
INFO: Elapsed time: 1804.531s
Below is my WORKSPACE file
# Maven dependencies
RULES_JVM_EXTERNAL_TAG = "4.5"
RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"
http_archive(
    name = "rules_jvm_external",
    sha256 = RULES_JVM_EXTERNAL_SHA,
    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)
load("@rules_jvm_external//:defs.bzl", "maven_install")
load(":maven_artifacts.bzl", "MAVEN_ARTIFACTS", "MAVEN_EXCLUDED_ARTIFACTS")
maven_install(
    artifacts = MAVEN_ARTIFACTS + IO_GRPC_GRPC_JAVA_ARTIFACTS,
    excluded_artifacts = MAVEN_EXCLUDED_ARTIFACTS,
    generate_compat_repositories = True,
    repositories = [
        "https://repo.maven.apache.org/maven2/",
        "https://maven.google.com/",
    ],
    resolve_timeout = 1800,
)
                                    
                                    
                                    
                                
How big is the artifact list? You could debug the repository rule and try running the coursier command directly from the command line.
It is around 125 artifacts. Any guide I can refer on how to run coursier command from command line?
https://github.com/bazelbuild/rules_jvm_external#verbose--debug-mode should show you the command.
Also, if you can even get it to succeed once, use artifact pinning to lock down the dependencies and switch to use Bazel's downloader.