Skip to content

Commit

Permalink
Use the shipped Bundler on TruffleRuby 22.0
Browse files Browse the repository at this point in the history
* To workaround oracle/truffleruby#2586
  • Loading branch information
eregon committed Jan 28, 2022
1 parent fabf251 commit 359bebb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}

if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 2.2) {
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)) {
Expand All @@ -82,7 +84,10 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
bundlerVersion = '1'
}

if (common.isHeadVersion(rubyVersion) && common.isBundler2Default(engine, rubyVersion) && bundlerVersion.startsWith('2')) {
// Workaround for truffleruby 22.0 + latest Bundler, use shipped Bundler instead: https://github.com/oracle/truffleruby/issues/2586
const useShippedBundler2 = common.isHeadVersion(rubyVersion) || (engine.startsWith('truffleruby') && rubyVersion.startsWith('22.0'))

if (useShippedBundler2 && common.isBundler2Default(engine, rubyVersion) && bundlerVersion.startsWith('2')) {
// Avoid installing a newer Bundler version for head versions as it might not work.
// For releases, even if they ship with Bundler 2 we install the latest Bundler.
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
Expand All @@ -92,7 +97,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
const gem = path.join(rubyPrefix, 'bin', 'gem')
const bundlerVersionConstraint = /^\d+\.\d+\.\d+/.test(bundlerVersion) ? bundlerVersion : `~> ${bundlerVersion}`
// Workaround for https://github.com/rubygems/rubygems/issues/5245
const force = (platform.startsWith('windows-') && engine === 'ruby' && common.floatVersion(rubyVersion) >= 3.1) ? ['--force'] : []
const force = (platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) ? ['--force'] : []
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
}

Expand Down
11 changes: 8 additions & 3 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 359bebb

Please sign in to comment.