You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Choose appropriate minimum JDK for JRuby versions #718
JRuby 10 is just about to be released, and master (now hosting 10) will become jruby-head once we unlock jruby-dev-builder (ruby/jruby-dev-builder#9). JRuby 10, unlike 9.4, depends on JDK 21 minimum. Because GHA defaults JAVA_HOME to a Java 17 install, we need to adjust that for all setup-ruby use on JRuby >= 10-snapshot.
Users of JRuby 10 should not have to perform an additional step to choose the proper JDK level, and we can't flip jruby-head builds to 10 until this is fixed.
I am not familiar enough with the codebase or GHA to know where to put this code. The basic requirement is to detect that we're setting up a JRuby version (head or 10+) that requires JDK 21, and alter the JAVA_HOME environment variable to point at the contents of the platform-appropriate JAVA_HOME_21_* variable (see https://github.com/actions/runner-images/discussions/9266 for some discussion on that).
IOW I think ideally we would detect if JAVA_HOME is the default, if it is switch to JAVA_HOME_21_X64 instead if available, for all other cases do nothing.
Regardless of the JRuby version if possible, to make it simpler (older JRuby should run fine on JDK 21, maybe even faster).
We are seeing GitHub Actions failures on ubuntu-latest and jruby-head after this change:
Run ruby/setup-ruby@v1
Modifying PATH
Entries added to PATH to use selected Ruby:
/home/runner/.rubies/jruby-head/bin
Downloading Ruby
https://github.com/ruby/jruby-dev-builder/releases/latest/download/jruby-head-ubuntu-24.04.tar.gz
Took 1.38 seconds
Extracting Ruby
/usr/bin/tar -xz -C /home/runner/.rubies -f /home/runner/work/_temp/ab607910-b37c-4b92-85
Took 0.42 seconds
Print Ruby version
/home/runner/.rubies/jruby-head/bin/ruby --version
Unrecognized VM option 'AutoCreateSharedArchive'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Took 0.38 seconds
Error: The process '/home/runner/.rubies/jruby-head/bin/ruby' failed with exit code 1
You can also switch to JRuby 9.4 builds which is where the 9.4 maintenance line can be tested now. jruby-head is now JRuby 10, requiring Java 21 and supporting up to Ruby 3.4 features.
I think it might be better to add a section in README to instruct user to explicitly use https://github.com/actions/setup-java to configure JAVA_HOME if desired, and it needs to be run before setup-ruby. Implicitly changing user's JAVA_HOME might be OK for most of the use case but might also break in unexpected ways.
@ntkme My original suggestion was to call setup-java from setup-ruby. The main concern I have had is that everyone running jruby-head would immediately break because 21 is not the default JDK on GHA yet, and even when 10 is released we don't really want people to have to use setup-java. Basically, setup-ruby should make sure all prerequisites are on the system and working for all Rubies, and for us that means JDK 21 or higher.
The logic I came up with will only change JAVA_HOME if it is too old to run JRuby. If it is already set up (as by setup-java or by user) and works with JRuby, we will not alter JAVA_HOME from the user.
I'm willing to entertain some debate here, though!
@NC-piercej Thank you for confirming, and I guess that also means your library is good to go on JRuby 10!
@headius Another idea I have is to have jruby-builder/jruby-dev-builder create an archive that bundles JDK in it and create a ruby launcher wrapper that use the bundled JDK, so there will be no external dependency. In that case, we don't need to modify JAVA_HOME globally.
@ntkme That sounds similar to a question @eregon asked about JRuby having a separate environment variable for Java home. We don't have such a feature currently, but I could see JRUBY_JAVA_HOME being a good option to add to our launchers.
Activity
eregon commentedon Mar 10, 2025
Please take a look and make a PR yourself, it should be fairly simple.
See
setup-ruby/index.js
Lines 55 to 59 in 277ba2a
so the installer for JRuby is always ruby-builder.js: https://github.com/ruby/setup-ruby/blob/master/ruby-builder.js
It seems best to set JAVA_HOME just after
setup-ruby/ruby-builder.js
Line 50 in 277ba2a
As said in #684 (comment) the logic should be:
Regardless of the JRuby version if possible, to make it simpler (older JRuby should run fine on JDK 21, maybe even faster).
headius commentedon Mar 11, 2025
I am reluctant to switch all existing JRuby 9.4 users to Java 21. It will run fine, and may be faster, but they did not opt into such a change.
However, if it becomes a problem people are concerned about, we can address it then. Hopefully most will not notice.
Switch JAVA_HOME to 21 for JRuby
Switch JAVA_HOME to 21 for JRuby
Switch JAVA_HOME to 21 for JRuby (#721)
eregon commentedon Mar 12, 2025
PR merged, thanks.
NC-piercej commentedon Mar 13, 2025
We are seeing GitHub Actions failures on
ubuntu-latestandjruby-headafter this change:Seems to be related?
headius commentedon Mar 13, 2025
Yeah sorry about that... issues that only came up once everything was released. We're working on it in #722.
You may be able to work around it yourself by using setup-java to install Java 21, or reset env
JAVA_HOMEtoJAVA_HOME_21_X64.headius commentedon Mar 13, 2025
Doing these things before setup-ruby, that is.
headius commentedon Mar 13, 2025
You can also switch to JRuby 9.4 builds which is where the 9.4 maintenance line can be tested now.
jruby-headis now JRuby 10, requiring Java 21 and supporting up to Ruby 3.4 features.eregon commentedon Mar 13, 2025
Fixed by #722 and released as https://github.com/ruby/setup-ruby/releases/tag/v1.225.0
headius commentedon Mar 13, 2025
@eregon Thank you for merging and releasing.
@NC-piercej Can you confirm your builds are working with jruby-head again?
ntkme commentedon Mar 13, 2025
I think it might be better to add a section in README to instruct user to explicitly use https://github.com/actions/setup-java to configure JAVA_HOME if desired, and it needs to be run before setup-ruby. Implicitly changing user's JAVA_HOME might be OK for most of the use case but might also break in unexpected ways.
NC-piercej commentedon Mar 13, 2025
I can confirm it is back to working again! 🎉
headius commentedon Mar 13, 2025
@ntkme My original suggestion was to call setup-java from setup-ruby. The main concern I have had is that everyone running jruby-head would immediately break because 21 is not the default JDK on GHA yet, and even when 10 is released we don't really want people to have to use setup-java. Basically, setup-ruby should make sure all prerequisites are on the system and working for all Rubies, and for us that means JDK 21 or higher.
The logic I came up with will only change JAVA_HOME if it is too old to run JRuby. If it is already set up (as by setup-java or by user) and works with JRuby, we will not alter JAVA_HOME from the user.
I'm willing to entertain some debate here, though!
@NC-piercej Thank you for confirming, and I guess that also means your library is good to go on JRuby 10!
ntkme commentedon Mar 13, 2025
@headius Another idea I have is to have jruby-builder/jruby-dev-builder create an archive that bundles JDK in it and create a ruby launcher wrapper that use the bundled JDK, so there will be no external dependency. In that case, we don't need to modify JAVA_HOME globally.
headius commentedon Mar 13, 2025
@ntkme That sounds similar to a question @eregon asked about JRuby having a separate environment variable for Java home. We don't have such a feature currently, but I could see JRUBY_JAVA_HOME being a good option to add to our launchers.