Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup 'rubygems: latest' #551

Merged
merged 1 commit into from Dec 27, 2023
Merged

Fixup 'rubygems: latest' #551

merged 1 commit into from Dec 27, 2023

Conversation

MSP-Greg
Copy link
Collaborator

@MSP-Greg MSP-Greg commented Dec 24, 2023

Fixes using 'rubygems; latest' for MRI Ruby 2.3 and later. I tried updating Ruby 2.2 and got errors for two different versions.

gem update --system will not allow a bounded version, only an exact version. So, code is somewhat brittle if new patch releases are done for older RubyGems versions.

Code works same as existing for non MRI Rubies.

One thing I wasn't sure about is whether Ruby master/head builds should not have anything done for 'rubygems; latest'. Sometime this year I think the RubyGems version was a pre-release, so latest would install an earlier version? Not.Sure.

Happy Holidays...

@MSP-Greg
Copy link
Collaborator Author

Added a second commit which skips gem update --system for Ruby master/head builds. Added a note to action.yml.

@MSP-Greg
Copy link
Collaborator Author

JFYI...

Puma separates MRI & non MRI CI.

In MRI CI, we didn't use the rubygems input, as it really didn't work. We added a step to fix RubyGems/Bundler in older Rubies. Note that Puma CI tests Bundler functionality, as it's used when restarting/reloading Puma.

I used this PR in Puma CI, and it works as expected. I removed the additional step needed for older Rubies.

Head builds are left alone, and Rubies are upgraded with the proper version of RubyGems. We test Ruby 2.4 and later on all platforms.

Happy Holidays, Greg

@MSP-Greg
Copy link
Collaborator Author

MSP-Greg commented Dec 26, 2023

Note that with the release of RubyGems 3.5.x (restricted to Ruby 3.x), in current master all Ruby versions 2.x fail when the rubygems input is set to latest.

See https://github.com/MSP-Greg/setup-ruby/actions/runs/7330308381

@MSP-Greg
Copy link
Collaborator Author

@eregon

Any thoughts on TruffleRuby and maybe JRuby? Handle like Ruby head builds?

@eregon
Copy link
Member

eregon commented Dec 27, 2023

Indeed I noticed https://github.com/ruby/setup-ruby/actions/runs/7324250188/job/19947638571 thank you for the fix!

@eregon
Copy link
Member

eregon commented Dec 27, 2023

Any thoughts on TruffleRuby and maybe JRuby? Handle like Ruby head builds?

TruffleRuby ignores gem update --system currently so nothing special to do there.
For JRuby I don't know, but simpler is better (i.e. let's keep as-is).

@@ -28,3 +28,19 @@ export async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {

return true
}

async function rubygemsLatest(gem, platform, engine, version) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a link here to rubygems/rubygems#7329 or another appropriate issue explaining why we need to workaround this bug in RubyGems?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned, this has always been an issue, but since it's only tested here on Ruby 2.6, it failed because of the recently changed minimum Ruby version in RubyGems.

RubyGems 3.4 supported Ruby 2.6 and later, RubyGems 3.5 supports Ruby 3.0 and later.

yarn.lock Outdated
version "2.1.1"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.1.1.tgz#a8e97699c315bed0ecaeaaeb640948470d4586a0"
integrity sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==
version "2.2.0"
Copy link
Member

@eregon eregon Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you undo all changes in yarn.lock?
They can cause failures, etc and updating usually makes it worse more than it helps from past experience.
In any case updating it should be done in its own commit&PR so easy to revert if any issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll split the yarn.lock changes.

rubygems.js Outdated

async function rubygemsLatest(gem, platform, engine, version) {
if (engine === 'ruby') {
if (version >= '3.0') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing versions as strings feels brittle, could you use common.floatVersion() instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expecting a x.10 version? Regardless, I'll update.

rubygems.js Outdated
console.log(`Cannot update RubyGems for Ruby version ${version}`)
}
} else {
exec.exec(gem, ['update', '--system'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that line is only for non MRI Ruby. Given our/my lack of knowledge of JRuby, remove it and log a message that RubyGems is not updated on non MRI platforms?

Nevermind, I'll fix it as you've listed above. So, same behavior as current with non MRI.

fail-fast: false
matrix:
include:
- { ruby: '3.2', rg_vers: '3.5.3' }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rg_vers -> rubygems_version/expected_version/expected_rubygems_version (abbreviations are an overhead on readability if not super well known ones)

rubygems: latest
- run: ruby -e "exit(Gem.rubygems_version > Gem::Version.new('3.0.3'))"
- run: ruby -e "puts Gem::VERSION; exit(Gem.rubygems_version >= Gem::Version.new('${{ matrix.rg_vers }}'))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you swap single and double quotes? It's safer to use single quotes outside for Ruby code (was already an issue before but since you're touching this line let's do it)

action.yml Outdated
@@ -12,7 +12,7 @@ inputs:
description: |
The version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5).
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
For 'latest', `gem update --system` is run to update to the proper latest RubyGems version. Ruby head/master builds and Ruby 2.2 and earlier will not be updated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep a sentence per line

action.yml Outdated
@@ -12,7 +12,7 @@ inputs:
description: |
The version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5).
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
For 'latest', `gem update --system` is run to update to the proper latest RubyGems version. Ruby head/master builds and Ruby 2.2 and earlier will not be updated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proper latest RubyGems -> latest compatible RubyGems

@eregon
Copy link
Member

eregon commented Dec 27, 2023

@MSP-Greg I'm curious, why do you update RubyGems in Puma's CI?
I don't recall any reason to update RubyGems in CI at the moment.

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great but needs some polishing (see comments)

@MSP-Greg
Copy link
Collaborator Author

MSP-Greg commented Dec 27, 2023

I'm curious, why do you update RubyGems in Puma's CI?

Honestly, I can't recall. I wrote the code and included a note with required_ruby_version. Older RubyGems/Bundler were very quirky with that, especially when one throws in cross-platform and pre-compiled gems being available.

but needs some polishing

Not a good phrase to use. Conversely, I guess I shouldn't write code when I'm also doing 'pre Christmas Eve dinner prep'...

This issue has come up in the past, a few issues related. In one message you said:

I can't care less about Ruby 2.5 and old RubyGems bugs, that's the problem of anyone still using Ruby 2.5.

I've advocated using newer Ruby versions, and also using head builds in CI, but I also understand testing against older versions.

As you've stated, this is fixing 'old RubyGems bugs'. I believe current RubyGems/Bundler has fixed all the bugs (thanks to some hard work by very few people).

Although this code may need the RubyGems versions updated from time to time (so it's a burden here), this fix will benefit others that maybe aren't as familiar with all the issues involved with older RubyGems, cross-platform CI and scripting, etc, etc. For others, it may cleanup their Actions workflow scripts...

@MSP-Greg
Copy link
Collaborator Author

@eregon I think I fixed/updated all items.

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@eregon eregon merged commit 28f9302 into ruby:master Dec 27, 2023
166 checks passed
@eregon
Copy link
Member

eregon commented Dec 27, 2023

Honestly, I can't recall. I wrote the code and included a note with required_ruby_version. Older RubyGems/Bundler were very quirky with that, especially when one throws in cross-platform and pre-compiled gems being available.

No worries.

but needs some polishing

Not a good phrase to use. Conversely, I guess I shouldn't write code when I'm also doing 'pre Christmas Eve dinner prep'...

What's wrong with it? I didn't mean anything bad. Is "needs some cleanup" better?
I just meant review should be addressed before merging, because it's not just trivial/stylistic things (which could be cleaned up separately later easily).
But it's fairly obvious so maybe I shouldn't have said anything.

This issue has come up in the past, a few issues related. In one message you said:

I can't care less about Ruby 2.5 and old RubyGems bugs, that's the problem of anyone still using Ruby 2.5.

Yeah in general I'm unhappy to have to workaround RubyGems/Bundler bugs, specifically I want to ensure such bugs are properly known upstream and fixed there, but I understand in cases such as this one (where we cannot fix RubyGems shipped with some old Ruby) it's warranted.
I'm still unsure whether updating RubyGems is ever necessary/a good idea or it brings more problems than it helps (that's my current impression based on a few cases of people trying to use it and asking help). But regardless of that I don't want to reopen that debate here and it does seem some people use it.
I appreciate your PR to fix this.

I've advocated using newer Ruby versions, and also using head builds in CI, but I also understand testing against older versions.

The fact this action supports Ruby 1.9 means we try to support as much as possible, but still stay reasonable and simple and e.g. not accumulate many fixes for old Rubies (e.g. if it doesn't compile anymore, we don't try to patch that Ruby, it's just not available).
IMO if there is something in the ecosystem breaking for ancient Rubies it's a good push to stop supporting that Ruby in gems (BTW I wouldn't consider 2.7 ancient yet).

@MSP-Greg MSP-Greg deleted the 00-rubygems-latest branch December 27, 2023 20:44
@dentarg
Copy link

dentarg commented Dec 28, 2023

I'm curious, why do you update RubyGems in Puma's CI?
I don't recall any reason to update RubyGems in CI at the moment.

Here's an example from Sinatra CI, on Ruby 3.0 we use latest RubyGems version: https://github.com/sinatra/sinatra/blob/5d844eecdc349d32c5c7de72fe68b5ebaafdbee5/.github/workflows/test.yml#L63-L70 due to rubygems/rubygems#6490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants