Skip to content

Commit

Permalink
Fixes the latest rubygems installation error with Ruby 3.0
Browse files Browse the repository at this point in the history
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@1
        with:
          ruby-version: "3.0"
          rubygems: latest
```
  • Loading branch information
Watson1978 committed Dec 19, 2024
1 parent 401c19e commit c8ac511
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion rubygems.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ async function rubygemsLatest(gem, platform, engine, rubyVersion) {
const floatVersion = common.floatVersion(rubyVersion)
if (common.isHeadVersion(rubyVersion)) {
console.log('Ruby master builds use included RubyGems')
} else if (floatVersion >= 3.0) {
} else if (floatVersion >= 3.1) {
await exec.exec(gem, ['update', '--system'])
} else if (floatVersion >= 3.0) {
await exec.exec(gem, ['update', '--system', '3.5.23'])
} else if (floatVersion >= 2.6) {
await exec.exec(gem, ['update', '--system', '3.4.22'])
} else if (floatVersion >= 2.3) {
Expand Down

0 comments on commit c8ac511

Please sign in to comment.