Skip to content

Commit

Permalink
Fix automatic bundler installation on JRuby 9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach authored and eregon committed Dec 25, 2022
1 parent 5fe1a66 commit 03b78bd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
9 changes: 5 additions & 4 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
}
}

// Use Bundler 2.3 when we use Ruby 2.3.2-2.5
const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion)
// Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
// Use Bundler 2.4 when we use Ruby 2.6-2.7
if (bundlerVersion == '2') {
if (engine === 'ruby' && floatVersion <= 2.5) {
console.log('Ruby 2.3.2-2.5 only works with Bundler 2.3')
if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above
console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3')
bundlerVersion = '2.3'
} else if (engine === 'ruby' && floatVersion <= 2.7) {
} else if (targetRubyVersion <= 2.7) {
console.log('Ruby 2.6-2.7 only works with Bundler 2.4')
bundlerVersion = '2.4'
}
Expand Down
17 changes: 17 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ export function isBundler2dot2Default(engine, rubyVersion) {
}
}

export function targetRubyVersion(engine, rubyVersion) {
const version = floatVersion(rubyVersion)
if (engine === 'ruby') {
return version
} else if (engine === 'jruby') {
if (version === 9.1) {
return 2.3
} else if (version === 9.2) {
return 2.5
} else if (version === 9.3) {
return 2.6
}
}

return 9.9 // unknown, assume recent
}

export function floatVersion(rubyVersion) {
const match = rubyVersion.match(/^\d+\.\d+/)
if (match) {
Expand Down
27 changes: 23 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03b78bd

Please sign in to comment.