Explicitly use Bundler 2 if there is no version specified

* Avoid issues when using --conservative as seen in
  https://github.com/ruby/setup-ruby/pull/48, clarifies what's getting
  installed and simplifies the following logic.
* We'll probably need changes when Bundler 3 comes out anyway.
This commit is contained in:
Benoit Daloze
2020-04-03 23:57:16 +02:00
parent 95135e9903
commit c68e25cb8c
2 changed files with 18 additions and 14 deletions
Generated Vendored
+9 -7
View File
@@ -1058,7 +1058,7 @@ function setupPath(ruby, newPathEntries) {
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
if (cleanPath.length !== originalPath.length) {
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
@@ -1100,14 +1100,15 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
}
}
let versionArray
if (bundlerVersion === 'latest') {
bundlerVersion = '2'
}
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
versionArray = ['-v', '~> 1']
bundlerVersion = '1'
} else if (/^\d+/.test(bundlerVersion)) {
versionArray = ['-v', `~> ${bundlerVersion}`]
} else if (bundlerVersion === 'latest') {
versionArray = []
// OK
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
@@ -1117,7 +1118,8 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
console.log(`Using the Bundler version shipped with ${engine}`)
} else {
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
const gem = path.join(rubyPrefix, 'bin', 'gem')
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
}
}
+9 -7
View File
@@ -100,7 +100,7 @@ function setupPath(ruby, newPathEntries) {
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
if (cleanPath.length !== originalPath.length) {
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
@@ -142,14 +142,15 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
}
}
let versionArray
if (bundlerVersion === 'latest') {
bundlerVersion = '2'
}
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
versionArray = ['-v', '~> 1']
bundlerVersion = '1'
} else if (/^\d+/.test(bundlerVersion)) {
versionArray = ['-v', `~> ${bundlerVersion}`]
} else if (bundlerVersion === 'latest') {
versionArray = []
// OK
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
@@ -159,7 +160,8 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
console.log(`Using the Bundler version shipped with ${engine}`)
} else {
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
const gem = path.join(rubyPrefix, 'bin', 'gem')
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
}
}