Skip to content

Commit

Permalink
Use latest Bundler on CRuby 2.6 and 2.7 as their default Bundler is t…
Browse files Browse the repository at this point in the history
…oo old
  • Loading branch information
eregon committed Jul 26, 2022
1 parent bb1d54f commit e8f04a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
14 changes: 10 additions & 4 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,19 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
}
}

const floatVersion = common.floatVersion(rubyVersion)

if (bundlerVersion === 'default') {
if (common.isBundler2Default(engine, rubyVersion)) {
if (engine === 'ruby' && floatVersion < 3.0 && common.hasBundlerDefaultGem(engine, rubyVersion)) {
// Ruby 2.6 and 2.7 have a old Bundler default gem which does not work well for `gem 'foo', github: 'foo/foo'`:
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
// Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
console.log(`Using latest Bundler for ${engine}-${rubyVersion} because the default Bundler gem is too old for that Ruby version`)
bundlerVersion = 'latest'
} else if (common.isBundler2Default(engine, rubyVersion)) {
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
return '2'
} else if (common.isBundler1Default(engine, rubyVersion)) {
} else if (common.isBundler1Default(engine, rubyVersion) && engine !== 'ruby') {
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
return '1'
} else {
Expand All @@ -90,8 +98,6 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}

const floatVersion = common.floatVersion(rubyVersion)

// Use Bundler 1 when we know Bundler 2 does not work
if (bundlerVersion.startsWith('2')) {
if (engine === 'ruby' && floatVersion <= 2.2) {
Expand Down
4 changes: 4 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export function isStableVersion(rubyVersion) {
return /^\d+(\.\d+)*$/.test(rubyVersion)
}

export function hasBundlerDefaultGem(engine, rubyVersion) {
return isBundler1Default(engine, rubyVersion) || isBundler2Default(engine, rubyVersion)
}

export function isBundler1Default(engine, rubyVersion) {
if (engine === 'ruby') {
return floatVersion(rubyVersion) >= 2.6 && floatVersion(rubyVersion) < 2.7
Expand Down
19 changes: 15 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 e8f04a3

Please sign in to comment.