Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables defined in toolchains.xml are incorrect on ARM runners #89

Closed
hfhbd opened this issue Mar 23, 2024 · 4 comments · Fixed by #150
Closed

Environment variables defined in toolchains.xml are incorrect on ARM runners #89

hfhbd opened this issue Mar 23, 2024 · 4 comments · Fixed by #150
Labels
bug Something isn't working in:setup-gradle
Milestone

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Mar 23, 2024

The toolchain.xml contains x86 env variables which aren't guaranteed to exist on arm, like macOS-14 (M1) or Ubuntu Arm runners (currently in private Beta), or on any custom hosted runner:

<!-- JDK Toolchains installed by default on GitHub-hosted runners -->
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>8</version>
      <vendor>Eclipse Temurin</vendor>
    </provides>
    <configuration>
      <jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
    </configuration>
  </toolchain>

When using Gradle, this results into these warnings on macOS-14 (M1)/Ubuntu Arm:

Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_8_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_21_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_11_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/8.7-rc-3/${env.JAVA_HOME_17_X64}' (Maven Toolchains) used for java installations does not exist

After using setup-java with 21, on Ubuntu Arm there is only one env: JAVA_HOME_21_ARM64=/home/runner/work/_tool/Java_Adopt_jdk/21.0.2-13.0.LTS/arm64

@bigdaz
Copy link
Member

bigdaz commented Mar 25, 2024

Thanks for your report. The reason for the hard-coded toolchains.xml file is to ensure that pre-installed JDKs are used when Gradle resolves a Java toolchain. Without this, Gradle will download a JDK even when the same one is already installed on the runner.

To support ARM equally, we need to choose between:

  1. Removing this hard-coded list. Users will need to use setup-java (which adds to toolchains.xml) in order to benefit from pre-installed JDKs.
  2. Add a separate hard-coded toolchains list for ARM.
  3. Add the _arm equivalents to the hard-coded list, and validate against the actual environment, removing any that are unknown.

My preference would be for the 3rd option. Are you interested in submitting a PR for this?

@hfhbd
Copy link
Contributor Author

hfhbd commented Mar 25, 2024

Are you interested in submitting a PR for this?

Yes

@bigdaz bigdaz changed the title toolchain.xml: Support ARM/Drop x86 Environment variables defined in toolchains.xml are incorrect on ARM runners Apr 1, 2024
@bigdaz bigdaz added bug Something isn't working in:setup-gradle labels Apr 5, 2024
bigdaz added a commit that referenced this issue Apr 10, 2024
Different runners have different JDKs installed, so using a hard-coded
list for
`toolchains.xml` doesn't work. With this change, the file is generated
based on the available `JAVA_HOME_*` environment variables.

Fixes #89 

Thanks @hfhbd for the contribution!

Co-authored-by: hfhbd <22521688+hfhbd@users.noreply.github.com>
@bigdaz bigdaz added this to the v3.3 milestone Apr 11, 2024
@TWiStErRob
Copy link

We're still seeing these warnings on a self-hosted ubuntu runner (that looks like it's ubuntu-2204 image running on a beefier machine)

gradle/actions/setup-gradle@v3 (SHA:d9c87d481d55275bb5441eef3fe0e46805f9ef70 / 3.5.0)

Directory '/home/runner/.gradle/daemon/7.6.1/${env.JAVA_HOME_21_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/7.6.1/${env.JAVA_HOME_11_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/7.6.1/${env.JAVA_HOME_8_X64}' (Maven Toolchains) used for java installations does not exist
Directory '/home/runner/.gradle/daemon/7.6.1/${env.JAVA_HOME_17_X64}' (Maven Toolchains) used for java installations does not exist

We do have setup-java:

Run actions/setup-java@v4
Installed distributions
  Resolved Java 17.0.11+9 from tool-cache
  Setting Java 17.0.11+9 as the default
  Creating toolchains.xml for JDK version 17 from temurin
  Writing to /home/runner/.m2/toolchains.xml
  
  Java configuration:
    Distribution: temurin
    Version: 17.0.11+9
    Path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.11-9/x64
  
Creating settings.xml with server-id: github
Writing to /home/runner/.m2/settings.xml

@bigdaz
Copy link
Member

bigdaz commented Jul 31, 2024

@TWiStErRob Can you please check a few things:

  • Does the setup-java step precede the setup-gradle step in your workflow?
  • The warnings you see: are they emitted by the setup-gradle step, or by a later step that executes a Gradle build?
  • Are the referenced environment variables (eg JAVA_HOME_21_X64) defined at the point the warnings are emitted, and do they provide an absolute path to an installed JDK?
  • What is the content of /home/runner/.m2/toolchains.xml both before and after the setup-gradle step?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in:setup-gradle
Projects
None yet
3 participants