From 82eb2557ac74a1e1b5dabd9494cff77413d33227 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 13 Mar 2025 12:36:12 -0500 Subject: [PATCH 1/2] Handle exec error Apparently this exec errors when the subprocess fails rather than returning an error code. This causes the whole setup process to terminate. This patch catches the error and uses that to indicate failure to launch. --- common.js | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.js b/common.js index f66798e44..c8b861465 100644 --- a/common.js +++ b/common.js @@ -409,7 +409,7 @@ export async function setupJavaHome() { await measure("Modifying JAVA_HOME for JRuby", async () => { console.log("attempting to run with existing JAVA_HOME") - let ret = await exec.exec('ruby', ['--version']) + let ret = await exec.exec('ruby', ['--version'], {ignoreReturnCode: true}) if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") diff --git a/dist/index.js b/dist/index.js index 1c0de8e91..a657f40d9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -729,7 +729,7 @@ async function setupJavaHome() { await measure("Modifying JAVA_HOME for JRuby", async () => { console.log("attempting to run with existing JAVA_HOME") - let ret = await exec.exec('ruby', ['--version']) + let ret = await exec.exec('ruby', ['--version'], {ignoreReturnCode: true}) if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") From 31ccf0680a4a33eeca6bbcb658f3f60873d0f470 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 13 Mar 2025 13:53:47 -0500 Subject: [PATCH 2/2] Test successful JRuby start without using launcher Native launcher appears to hang on GHA when the JDK version is too old for JRuby 10. This bypasses it and should be a bit lighter. It will also avoid any variability in the launcher used, since Unixes and Windows already use different executables. --- common.js | 4 ++-- dist/index.js | 6 +++--- ruby-builder.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common.js b/common.js index c8b861465..153af3d6f 100644 --- a/common.js +++ b/common.js @@ -405,11 +405,11 @@ export function setupPath(newPathEntries) { return msys2Type } -export async function setupJavaHome() { +export async function setupJavaHome(rubyPrefix) { await measure("Modifying JAVA_HOME for JRuby", async () => { console.log("attempting to run with existing JAVA_HOME") - let ret = await exec.exec('ruby', ['--version'], {ignoreReturnCode: true}) + let ret = await exec.exec('java', ['-jar', path.join(rubyPrefix, 'lib/jruby.jar'), '--version'], {ignoreReturnCode: true}) if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") diff --git a/dist/index.js b/dist/index.js index a657f40d9..3777b30df 100644 --- a/dist/index.js +++ b/dist/index.js @@ -725,11 +725,11 @@ function setupPath(newPathEntries) { return msys2Type } -async function setupJavaHome() { +async function setupJavaHome(rubyPrefix) { await measure("Modifying JAVA_HOME for JRuby", async () => { console.log("attempting to run with existing JAVA_HOME") - let ret = await exec.exec('ruby', ['--version'], {ignoreReturnCode: true}) + let ret = await exec.exec('java', ['-jar', path.join(rubyPrefix, 'lib/jruby.jar'), '--version'], {ignoreReturnCode: true}) if (ret === 0) { console.log("JRuby successfully starts, using existing JAVA_HOME") @@ -74091,7 +74091,7 @@ async function install(platform, engine, version) { // Ensure JRuby has minimum Java version to run if (engine === "jruby") { - await common.setupJavaHome() + await common.setupJavaHome(rubyPrefix) } return rubyPrefix diff --git a/ruby-builder.js b/ruby-builder.js index 6ec7e191d..ad8682ea1 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -56,7 +56,7 @@ export async function install(platform, engine, version) { // Ensure JRuby has minimum Java version to run if (engine === "jruby") { - await common.setupJavaHome() + await common.setupJavaHome(rubyPrefix) } return rubyPrefix