Skip to content

Commit d6a695a

Browse files
committed
Do not install Bundler if RubyGems was updated
* Updating RubyGems will install Bundler as a side effect. * Fixes #326
1 parent e404913 commit d6a695a

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ inputs:
1515
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
1616
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
1717
Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems, as long as that version is newer than the one provided by default.
18-
Defaults to 'default'.
18+
required: false
19+
default: 'default'
1920
bundler:
2021
description: |
2122
The version of Bundler to install. Either 'none', 'latest', 'Gemfile.lock', or a version number (e.g., 1, 2, 2.1, 2.1.4).

bundler.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ async function afterLockFile(lockFile, platform, engine, rubyVersion) {
5050
}
5151
}
5252

53-
export async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefix, engine, rubyVersion) {
53+
export async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, platform, rubyPrefix, engine, rubyVersion) {
5454
let bundlerVersion = bundlerVersionInput
5555

56+
if (rubygemsInputSet && bundlerVersion === 'default') {
57+
console.log('Using the Bundler installed by updating RubyGems')
58+
return 'unknown'
59+
}
60+
5661
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
5762
bundlerVersion = readBundledWithFromGemfileLock(lockFile)
5863

dist/index.js

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export async function setupRuby(options = {}) {
6666
await common.measure('Print Ruby version', async () =>
6767
await exec.exec('ruby', ['--version']))
6868

69-
if (inputs['rubygems'] !== 'default') {
69+
const rubygemsInputSet = inputs['rubygems'] !== 'default'
70+
if (rubygemsInputSet) {
7071
await common.measure('Updating RubyGems', async () =>
7172
rubygems.rubygemsUpdate(inputs['rubygems'], rubyPrefix))
7273
}
@@ -79,11 +80,11 @@ export async function setupRuby(options = {}) {
7980
}
8081

8182
const [gemfile, lockFile] = bundler.detectGemfiles()
82-
let bundlerVersion = "unknown"
83+
let bundlerVersion = 'unknown'
8384

8485
if (inputs['bundler'] !== 'none') {
8586
bundlerVersion = await common.measure('Installing Bundler', async () =>
86-
bundler.installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version))
87+
bundler.installBundler(inputs['bundler'], rubygemsInputSet, lockFile, platform, rubyPrefix, engine, version))
8788
}
8889

8990
if (inputs['bundler-cache'] === 'true') {

0 commit comments

Comments
 (0)