jbang icon indicating copy to clipboard operation
jbang copied to clipboard

Support for path `/opt/hostedtoolcache` for JDKs

Open koppor opened this issue 1 month ago • 1 comments

I use GitHub actions. I have

      - name: Set up JDK
        uses: actions/setup-java@v5
        with:
          java-version: 24
          distribution: 'corretto'
          check-latest: true
      - name: Set up JDK
        uses: actions/setup-java@v5
        with:
          java-version: 25
          distribution: 'corretto'
          check-latest: true

GitHub actions says:

   Java configuration:
    Distribution: corretto
    Version: 24.0.2+12.1
    Path: /opt/hostedtoolcache/Java_Corretto_jdk/24.0.2-12.1/x64
...

  Java configuration:
    Distribution: corretto
    Version: 25.0.1+9.1
    Path: /opt/hostedtoolcache/Java_Corretto_jdk/25.0.1-9.1/x64

Moreover, I get

Error:  [ERROR] No suitable JDK was found for requested version: 24
[jbang] Run with --verbose for more details. The --verbose must be placed before the jbang command. I.e. jbang --verbose run [...]

I don't understand - because JDK24 is available at /opt/hostedtoolcache/Java_Corretto_jdk/25.0.1-9.1/x64.

I need JDK 25 because of OpenRewrite and my JBang scripts have requirement on JDK24. (I changed the latter, but I wanted to raise this issue nevertheless)

koppor avatar Dec 09 '25 14:12 koppor

I'm not very well-versed with JBang in GitHub actions, so I'll let @maxandersen take a look at this, but I wanted to mention at least that we do actually support GH-installed JDKs, but we look for JAVA_HOME_NN, so if a JAVA_HOME_24 exists JBang should support switching to 24. But... that feature isn't enabled by default, so I'm guessing it's not enabled for GH actions by default either (although that would make sense).

Why the switch to 24 failed in this case is also not clear to me. It can be a temporary failure of the download service (which is not under our control), but without a verbose log we can't really tell what happened.

quintesse avatar Dec 09 '25 15:12 quintesse

Why the switch to 24 failed in this case is also not clear to me. It can be a temporary failure of the download service (which is not under our control),

Yes. For about one hour, there were issues with foojay. Returned 5xx.

My try was to create a workaround...

koppor avatar Dec 11 '25 19:12 koppor