nokogiri requires Ruby version >= 2.7, < 3.3.dev.

170 views
Skip to first unread message

Dave Thomson

unread,
Nov 21, 2023, 12:13:28 PM11/21/23
to nokogiri-talk
I'm trying to set up an old Rails project from 2017. It used ruby 2.4.1 and Rails 5.0.1.rc1

So far I have installed rvm and ruby 2.4.1.

I am now trying to install Rails before I clone the repo, so I went:

rvm gemset create rails501 
rvm 2.4.1@rails501 
gem install rails -v 5.0.1

Which resulted in:

There are no versions of nokogiri (~> 1.14) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
nokogiri requires Ruby version >= 2.7, < 3.3.dev. The current ruby version is 2.4.1.111.

I installed nokogiri 1.7.0 but same error, so this has to be something else


gem list

*** LOCAL GEMS ***

activesupport (5.0.1, 5.0.1.rc1)
bigdecimal (default: 1.3.0)
bundler (default: 1.17.3)
bundler-unload (1.0.2)
concurrent-ruby (1.2.2)
did_you_mean (1.1.0)
executable-hooks (1.6.1)
gem-wrappers (1.4.0)
i18n (0.9.5)
io-console (default: 0.4.6)
json (default: 2.0.2)
mini_portile2 (2.1.0)
minitest (5.10.1)
net-telnet (0.1.1)
nokogiri (1.7.0)
openssl (default: 2.0.3)
pkg-config (1.1.9)
power_assert (0.4.1)
psych (default: 2.2.2)
racc (1.5.2)
rake (12.0.0)
rdoc (default: 5.0.0)
rubygems-bundler (1.4.5)
rvm (1.11.3.9)
test-unit (3.2.3)
thread_safe (0.3.6)
tzinfo (1.2.11)
xmlrpc (0.2.1)

Mike Dalessio

unread,
Nov 28, 2023, 10:20:14 PM11/28/23
to nokogi...@googlegroups.com
Hi,

Thanks for asking this question. Ruby 2.4 is quite old, so you may be in for a bit of tough time. I'll also note that this is not a Nokogiri-specific question -- you're really asking, "how do I resolve dependencies for an old project using an old version of Ruby." But I'll try to help!

To describe what's going on: the "gem" tool is trying to resolve dependencies for rails v5.0.1 and it's doing it wrong. It's likely a version of rubygems that doesn't correctly take into account gems' `required_ruby_version` when resolving dependencies. It's curious that it's decided to look for "nokogiri (~> 1.14)" which doesn't match the default that Rails 5.0.1 needs, and isn't a valid version for Ruby 2.4; you may wish to try to discover where that version specification is coming from. The last version of Nokogiri to support Ruby 2.4 is 1.10.10 (it was removed from support in Nokogiri 1.11.0).

The best advice I can give you, particularly because you're using an old version of Ruby, is to use `bundler` and a Gemfile to declare and resolve your dependencies. Modern bundler generally knows how to resolve dependencies correctly for a wide variety of situations.

If you have a "Gemfile" and a "Gemfile.lock" for your project, then "bundle install" might just work and you're done.

If you don't have a "Gemfile.lock", but you do have a "Gemfile", then you'll need to resolve dependencies. Make sure to install and use the most recent version of bundler that supports Ruby 2.4. "gem install bundler" should work, but if it doesn't, find the most recent version that supports Ruby 2.4 and run "gem install bundler -v <VERSION>". Then try running "bundle install".

If you don't have a "Gemfile", then you'll need to piece together your application's dependencies. Start with a "Gemfile" that just contains your source line and a line declaring a rails dependency, run "bundle install", and then try to boot the app. See what fails, add it as a dependency, bundle-install, and try booting again. Repeat until you've assembled the dependencies.

Finally: if you can't use bundler for whatever reason, then upgrade to the latest version of rubygems (which provides the "gem" tool) that supports Ruby 2.4, and try "gem install rails" again.

If you're struggling with any of these steps (I'm not sure how familiar you are with bundler and rubygems), or they just don't work for you, you may wish to try asking this question in a more general Ruby forum.

Good luck!

-mike


--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nokogiri-talk/a108d095-7a6b-4564-9abe-d38840821f44n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages