From 9b993bc63c844327f1ff4675bcc1839b68483bed Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 2 May 2022 20:15:42 +0200 Subject: [PATCH] Use the given Bundler 1.x version if supplied on old Rubies * Fixes https://github.com/ruby/setup-ruby/issues/327 --- bundler.js | 21 ++++++++++++--------- dist/index.js | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/bundler.js b/bundler.js index 1097fe7..d28e114 100644 --- a/bundler.js +++ b/bundler.js @@ -78,15 +78,18 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock const floatVersion = common.floatVersion(rubyVersion) - if (engine === 'ruby' && floatVersion <= 2.2) { - console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2') - bundlerVersion = '1' - } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) { - console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') - bundlerVersion = '1' - } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same - console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') - bundlerVersion = '1' + // Use Bundler 1 when we know Bundler 2 does not work + if (bundlerVersion.startsWith('2')) { + if (engine === 'ruby' && floatVersion <= 2.2) { + console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2') + bundlerVersion = '1' + } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) { + console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') + bundlerVersion = '1' + } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same + console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') + bundlerVersion = '1' + } } // Workaround for truffleruby 22.0 + latest Bundler, use shipped Bundler instead: https://github.com/oracle/truffleruby/issues/2586 diff --git a/dist/index.js b/dist/index.js index 82b8074..500a7c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -92,15 +92,18 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p const floatVersion = common.floatVersion(rubyVersion) - if (engine === 'ruby' && floatVersion <= 2.2) { - console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2') - bundlerVersion = '1' - } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) { - console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') - bundlerVersion = '1' - } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same - console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') - bundlerVersion = '1' + // Use Bundler 1 when we know Bundler 2 does not work + if (bundlerVersion.startsWith('2')) { + if (engine === 'ruby' && floatVersion <= 2.2) { + console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2') + bundlerVersion = '1' + } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) { + console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') + bundlerVersion = '1' + } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same + console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1') + bundlerVersion = '1' + } } // Workaround for truffleruby 22.0 + latest Bundler, use shipped Bundler instead: https://github.com/oracle/truffleruby/issues/2586