sgammon / rules_graalvm

Build GraalVM native binaries with Bazel
Apache License 2.0
46 stars 13 forks source link

Configure path to graalvm #397

Open ayashjorden opened 5 months ago

ayashjorden commented 5 months ago

(I'll preface with that probably I'm doing something wrong. although I did read through the docs.)

Our Bazel builds are going through a proxy to fetch artifacts and I am hitting a 404 when rules_graalvm tries to download the CE 17.0.8:

ERROR: Analysis of target '<NATIVE_IMAGE_BAZEL_TARGET_NAME>' failed; build aborted: java.io.IOException: Error downloading [https://<INTERNAL_PROXY>/mirror-bazel-build/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz] to /tmp/path/to/graalvm/temp15971974762323443278/graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz: GET returned 404 Not Found

It seems that graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz does not exist on mirror-bazel-build: https://mirror.bazel.build/github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz

Configuration

WORKSPACE.bazel:

http_archive(
    name = "rules_graalvm",
    sha256 = "3ef2f1583a4849d03209a43b0b507f172299c3045e585b6ffa7144a2bc12ae18",
    strip_prefix = "rules_graalvm-0.11.2",
    urls = [
        "https://github.com/sgammon/rules_graalvm/releases/download/v0.11.2/rules_graalvm-0.11.2.zip",
    ],
)
load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")
graalvm_repository(
    name = "graalvm",
    distribution = "ce",  # `oracle`, `ce`, or `community`
    java_version = "17",  # `17`, `20`, `21`, or `22` as supported by the version provided
    version = "17.0.8",  # gvm sdk version format like `24.x.x` also supported
)
load("@rules_graalvm//graalvm:workspace.bzl", "register_graalvm_toolchains", "rules_graalvm_repositories")
rules_graalvm_repositories()

register_graalvm_toolchains()

BUILD.bazel:

load(
    "@rules_graalvm//graalvm:defs.bzl",
    "native_image",
)

native_image(
    deps = [
        ":db-config-bin"
    ],
    name = "db-config-bin-native",
    main_class = "package.name.ConfigAgent",
    visibility = ["//some/visibilty/publish:__pkg__"],
    native_image_tool = "@graalvm//:native-image",
)
  1. Reading through the docs i was not able to find a way to set the path to the graalvm folder/home.
  2. What else am I doing wrong?

Thanks!

sgammon commented 5 months ago

@ayashjorden I'm not sure at first glance why this is failing, but I will look into it. I don't see anything wrong with what you are doing, except native_image_tool doesn't need to be provided when you are using the new-style entrypoint (you are). It should be resolving GraalVM from Bazel Toolchains.

As for the download URL, it is valid, and so is the version tag. Bazel's mirror should be pulling from here: https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_macos-x64_bin.tar.gz

I get a 404 like you do. Bazel's mirror domain isn't used directly by rules_graalvm to my knowledge or as far as I can tell. Is that happening through a proxy or perhaps some configuration on your end?

rules_graalvm maps its own download URLs, directly to GitHub; for example, for the version you've specified (17.0.8):

https://github.com/sgammon/rules_graalvm/blob/13d4bd9e2b3dd43f0185086b4adc32a651dea1d0/internal/graalvm_bindist_map.bzl#L631-L640

I know Bazel's mirror maps a lot of GitHub repositories, but I am not sure if GraalVM's releases are available via their mirror.

sgammon commented 5 months ago

Also, thanks for reporting, and sorry for the delay. Tag me at @sgammon to get a faster response :) tags show up in my mentions which aren't polluted by Dependabot.