mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Fix bundler: with a minor version installing the wrong version
If passed `bundler: 2.2`, setup-ruby would install bundler 2.3, because it would generate a constraint that looks like `~> 2.2`. This unexpectedly installs the latest of the 2.x series, but the expectation is that it would install the latest of the 2.2.x series. Fixes #304
This commit is contained in:
committed by
Benoit Daloze
parent
bd94d6a504
commit
1a68550f2e
+6
-3
@@ -65,8 +65,8 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
|
||||
bundlerVersion = '2'
|
||||
}
|
||||
|
||||
if (/^\d+/.test(bundlerVersion)) {
|
||||
// OK
|
||||
if (/^\d+(?:\.\d+){0,2}$/.test(bundlerVersion)) {
|
||||
// OK - input is a 1, 2, or 3 part version number
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
@@ -95,9 +95,12 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
|
||||
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
|
||||
} else {
|
||||
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' && floatVersion >= 3.1) ? ['--force'] : []
|
||||
|
||||
const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
|
||||
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0`
|
||||
|
||||
await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user