diff --git a/bundler.js b/bundler.js index 59f969e94..a25d0e5ec 100644 --- a/bundler.js +++ b/bundler.js @@ -142,9 +142,10 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock const gem = path.join(rubyPrefix, 'bin', 'gem') const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length - const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0` + // Use --conservative to avoid reinstalling the exact same version if already installed. + const options = versionParts >= 3 ? ['-v', bundlerVersion, '--conservative'] : ['-v', `~> ${bundlerVersion}.0`] - await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint]) + await exec.exec(gem, ['install', 'bundler', ...options]) return bundlerVersion } diff --git a/dist/index.js b/dist/index.js index bb1e278d5..d18a5cf54 100644 --- a/dist/index.js +++ b/dist/index.js @@ -156,9 +156,10 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p const gem = path.join(rubyPrefix, 'bin', 'gem') const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length - const bundlerVersionConstraint = versionParts >= 3 ? bundlerVersion : `~> ${bundlerVersion}.0` + // Use --conservative to avoid reinstalling the exact same version if already installed. + const options = versionParts >= 3 ? ['-v', bundlerVersion, '--conservative'] : ['-v', `~> ${bundlerVersion}.0`] - await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint]) + await exec.exec(gem, ['install', 'bundler', ...options]) return bundlerVersion }