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

Rails (every version) no longer installs on Ruby 2.5 due to GlobalID 0.5 #42931

Closed
rally25rs opened this issue Aug 2, 2021 · 5 comments
Closed

Comments

@rally25rs
Copy link

rally25rs commented Aug 2, 2021

Steps to reproduce

From a clean machine with no versions of globalid already installed (or gem uninstall globalid to remove it)
Install Ruby 2.5.*
Install Rails 6.1.4 (pick any version. even versions from 7 yrs ago has a dependency specification globalid >= 0.{something})

$ ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin19]

$ gem uninstall -aIx
...output omitted...

$ gem install rails
Fetching activesupport-6.1.4.gem
Fetching tzinfo-2.0.4.gem
Fetching zeitwerk-2.4.2.gem
Fetching i18n-1.8.10.gem
Fetching concurrent-ruby-1.1.9.gem
Fetching minitest-5.14.4.gem
Fetching rack-2.2.3.gem
Fetching rack-test-1.1.0.gem
Fetching crass-1.0.6.gem
Fetching racc-1.5.2.gem
Fetching nokogiri-1.11.7-x86_64-darwin.gem
Fetching loofah-2.11.0.gem
Fetching rails-html-sanitizer-1.3.0.gem
Fetching rails-dom-testing-2.0.3.gem
Fetching builder-3.2.4.gem
Fetching erubi-1.10.0.gem
Fetching actionview-6.1.4.gem
Fetching actionpack-6.1.4.gem
Fetching activemodel-6.1.4.gem
Fetching activerecord-6.1.4.gem
Fetching activejob-6.1.4.gem
Fetching mini_mime-1.1.0.gem
Fetching actionmailer-6.1.4.gem
Fetching globalid-0.5.1.gem
Fetching actioncable-6.1.4.gem
Fetching marcel-1.0.1.gem
Fetching mail-2.7.1.gem
Fetching activestorage-6.1.4.gem
Fetching nio4r-2.5.7.gem
Fetching websocket-extensions-0.1.5.gem
Fetching websocket-driver-0.7.5.gem
Fetching actionmailbox-6.1.4.gem
Fetching actiontext-6.1.4.gem
Fetching railties-6.1.4.gem
Fetching sprockets-4.0.2.gem
Fetching sprockets-rails-3.2.2.gem
Fetching rails-6.1.4.gem
Fetching rake-13.0.6.gem
Fetching thor-1.1.0.gem
Fetching method_source-1.0.0.gem
Successfully installed concurrent-ruby-1.1.9
Successfully installed i18n-1.8.10
Successfully installed tzinfo-2.0.4
Successfully installed zeitwerk-2.4.2
Successfully installed minitest-5.14.4
Successfully installed activesupport-6.1.4
Successfully installed rack-2.2.3
Successfully installed rack-test-1.1.0
Successfully installed crass-1.0.6
Building native extensions. This could take a while...
Successfully installed racc-1.5.2
Successfully installed nokogiri-1.11.7-x86_64-darwin
Successfully installed loofah-2.11.0
Successfully installed rails-html-sanitizer-1.3.0
Successfully installed rails-dom-testing-2.0.3
Successfully installed builder-3.2.4
Successfully installed erubi-1.10.0
Successfully installed actionview-6.1.4
Successfully installed actionpack-6.1.4
Successfully installed activemodel-6.1.4
Successfully installed activerecord-6.1.4
ERROR:  Error installing rails:
	The last version of globalid (>= 0.3.6) to support your Ruby & RubyGems was 0.4.2. Try installing it with `gem install globalid -v 0.4.2` and then running the current command again
	globalid requires Ruby version >= 2.6.0. The current ruby version is 2.5.3.105.

Expected behavior

According to the Rails gemspec, Ruby 2.5.0 should be supported:
https://github.com/rails/rails/blob/v6.1.4/rails.gemspec#L12

Rails should install successfully, as it always had (until last week)

Actual behavior

ERROR:  Error installing rails:
    The last version of globalid (>= 0.3.6) to support your Ruby & RubyGems was 0.4.2. Try installing it with `gem install globalid -v 0.4.2` and then running the current command again
    globalid requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.

This is due to transitive dependency globalid dropping ruby 2.5 support, but rails still claims to support it.

Dependency tree:

rails 6.1.4: https://github.com/rails/rails/blob/v6.1.4/rails.gemspec#L37

  s.required_ruby_version     = ">= 2.5.0"

  s.add_dependency "activejob",     version

activejob: https://github.com/rails/rails/blob/v6.1.4/activejob/activejob.gemspec#L35

  s.required_ruby_version = ">= 2.5.0"

  s.add_dependency "globalid", ">= 0.3.6"

globalid: https://github.com/rails/globalid/blob/main/globalid.gemspec#L8

  s.required_ruby_version = '>= 2.6.0'

This drop of ruby support was made in the update from globalid 0.4 to 0.5.

I believe activejob should have it's dependency set to>= 0.3.6 <5.0.0
However all past versions of Rails (going back 7 yrs at least) had the dependency globalid >= ... so globalid has to be futureproof forever and never drop any version of ruby. (the real issue is that > should probably never be used as a transitive dependency version range)

System configuration

Rails version: 6.1.4 (any version will cause the same error though)

Ruby version: 2.5.0 (anything 2.5.* will cause the issue)

Workarounds

For those that run into this issue:

Workaround 1:

One workaround is given in the error output. If you manually install globalid 0.4.2 first, then gem install will use that already installed version instead of trying to pick up the latest 0.5.1

$ gem install globalid -v 0.4.2
$ gem install rails

will install successfully

Workaround 2:

As mentioned in the comments, it seems that newer versions of rubygems will automatically resolve this by falling back to the latst version that supports your version of ruby. However rubygems that ships with 2.5 did not have this feature. You can upgrade rubygems after installing ruby to resolve this issue.

$ gem update --system
$ gem install rails
@rally25rs rally25rs changed the title Rails (every version) no longer supports Ruby 2.5 due to GlobalID 0.5 Rails (every version) no longer installs on Ruby 2.5 due to GlobalID 0.5 Aug 2, 2021
@casperisfine
Copy link
Contributor

I was able to repro on using docker run -it rubylang/ruby:2.5.8-bionic.

But I was also able to workaround the issue with a bundle update --system, long story short, the rubygems that ships with ruby 2.5 is not smart enough to fallback to an older version.

@kaspth
Copy link
Contributor

kaspth commented Aug 2, 2021

Hey sorry about this, we figured Rubygems (and Bundler for later
In the process) would account for the Ruby version constraint. Is this with the latest Rubygems version on your Ruby 2.5 install?

@casperisfine
Copy link
Contributor

# 3.2.3 / 2020-12-22
## Bug fixes:

* Respect `required_ruby_version` and `required_rubygems_version`
  constraints when looking for `gem install` candidates. Pull request #4110
  by deivid-rodriguez

@rally25rs
Copy link
Author

rally25rs commented Aug 2, 2021

I was also able to workaround the issue with a bundle update --system, long story short, the rubygems that ships with ruby 2.5 is not smart enough to fallback to an older version.

Good to know! We ran into this issue with an Ansible automation script that was starting with a clean VM each time. I suspect it is just using the rubygems that ships with 2.5. I was going to "fix" it by having Ansible gem install globalid -v "~> 0.4.1" but gem update --system might be a better fix.

edit:

Confirmed that a gem update --system after installing ruby 2.5 also fixes this issue. I edited the original issue and added this to the "Workarounds" section at the end, to help out anyone else who runs into this issue.

@kaspth
Copy link
Contributor

kaspth commented Aug 2, 2021

I've just shipped globalid 0.5.2 to circumvent this since it's a gem under our purview. We may likely bump to 2.7+ when Rails 7 ships with the same requirement, but that's for later.

Thanks for the issue! Glad we found the gem update --system workaround too.

@kaspth kaspth closed this as completed Aug 2, 2021
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 22, 2021
0.5.1 (2021-07-27)

* New: Allow expiration to be turned off globally #128
* Fixed: Support for ruby-head #132
* Maintainance: Drop support for EOL'ed Rubies (< 2.6.0) and Rails 4.2


0.5.2 (2021-08-02)

* Add back Ruby 2.5 support so gem install rails works out of the box,
  thereby satisfying Rails' Ruby version requirement.  See rails/rails#42931
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants