Skip to content

Commit 540484a

Browse files
Watson1978eregon
authored andcommitted
Fixes the latest rubygems installation error with Ruby 3.0
If set up `rubygems: latest` in workflow, it will cause the error with Ruby 3.0 because the latest rubygems does not support Ruby 3.0. Ref. https://rubygems.org/gems/rubygems-update ### Error message ``` Updating RubyGems /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/gem --version 3.2.33 Default RubyGems version is 3.2.33 Updating RubyGems to latest version /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/gem update --system ERROR: Error installing rubygems-update: rubygems-update-3.6.1 requires Ruby version >= 3.1.0. The current ruby version is 3.0.7.220. ERROR: While executing gem ... (NoMethodError) undefined method `version' for nil:NilClass Updating rubygems-update Took 2.86 seconds Error: The process '/opt/hostedtoolcache/Ruby/3.0.7/x64/bin/gem' failed with exit code 1 ``` ### How to reproduce ``` uses: ruby/setup-ruby@v1 with: ruby-version: "3.0" rubygems: latest ```
1 parent 401c19e commit 540484a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ jobs:
190190
fail-fast: false
191191
matrix:
192192
include:
193-
- { ruby: '3.2', expected_rubygems_version: '3.5.3' }
194-
- { ruby: '3.0', expected_rubygems_version: '3.5.3' }
193+
- { ruby: '3.2', expected_rubygems_version: '3.6.1' }
194+
- { ruby: '3.0', expected_rubygems_version: '3.5.23' }
195195
- { ruby: '2.7', expected_rubygems_version: '3.4.22' }
196196
- { ruby: '2.6', expected_rubygems_version: '3.4.22' }
197197
- { ruby: '2.5', expected_rubygems_version: '3.3.27' }

dist/index.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rubygems.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ async function rubygemsLatest(gem, platform, engine, rubyVersion) {
3939
const floatVersion = common.floatVersion(rubyVersion)
4040
if (common.isHeadVersion(rubyVersion)) {
4141
console.log('Ruby master builds use included RubyGems')
42-
} else if (floatVersion >= 3.0) {
42+
} else if (floatVersion >= 3.1) {
4343
await exec.exec(gem, ['update', '--system'])
44+
} else if (floatVersion >= 3.0) {
45+
await exec.exec(gem, ['update', '--system', '3.5.23'])
4446
} else if (floatVersion >= 2.6) {
4547
await exec.exec(gem, ['update', '--system', '3.4.22'])
4648
} else if (floatVersion >= 2.3) {

0 commit comments

Comments
 (0)