ruby-on-railsrubynokogiri

No versions of nokogiri compatible with my Ruby


I am installing a 2017 Rails project from GitHub. It is my understanding I need to first install Ruby and Rails before cloning the project. The project uses Ruby 2.4.1 and Rails version 5.0.1, so I am attempting to install those specifically. I am on the latest version of Linux Mint Cinnamon.

I successfully installed Ruby 2.4.1.p111 using RVM after much difficulty with openssl. Before that I tried (literally) all other ways to install Ruby as per ruby-lang, and failed due to negligence, but I deleted each failed install/manager app before moving on. So currently only RVM exists.

Now I am attempting to install Rails 5.0.1.rc1, also using RVM.

From my 2017 install notes, I first sudo apt-get install nodejs

Then (assuming in the global gemset) gem install -V rails --version=5.0.1.rc1

Which gave me an error regarding incompatible racc, which I resolved as suggested in the error by

gem install racc -v 1.5.2

I ran the rails install again, this time:

ERROR:  Error installing rails:
    The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.10. Try installing it with `gem install nokogiri -v 1.10.10` and then running the current command again
    nokogiri requires Ruby version >= 2.7, < 3.3.dev. The current ruby version is 2.4.1.111.

So I installed nokogiri -v 1.10.10 as suggested and tried again, which gave error:

HEAD https://rubygems.org/api/v1/dependencies
404 Not Found
GET https://rubygems.org/prerelease_specs.4.8.gz
200 OK
GET https://rubygems.org/specs.4.8.gz
200 OK
...
/usr/share/rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini/nokogiri.rb
/usr/share/rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini/nokogirisax.rb
/usr/share/rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini/rexml.rb
Successfully installed activesupport-5.0.1
ERROR:  Error installing rails:
    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 then tried creating a gemset for rails 5.0.1 with:

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

but got the same error. I researched things for a day and a half, then resorted to calling the repair shop to book fixing my old linux machine which has literally disintegrated. I was hoping to work on project on new laptop. Still researching while waiting to take old laptop in to fix.

This currently is the gem list in 2.4.1@rails501 gemset:

gem query --local

*** LOCAL GEMS ***

activesupport (5.1.0)
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.2)
openssl (default: 2.0.3)
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)

Solution

  • You do not need to install the dependencies yourself, not even Rails, and you should not try. There's likely way way too many and you're likely to install versions that do not work with the project.

    The project should have a Gemfile.lock file which contains the exact dependencies known to work with the project. Install the newest possible version of Ruby the project will allow (if it wants Ruby 2.4 or 2.4.1, install 2.4.8; this is the same as 2.4.1 but with bug fixes).

    Then clone the repository and let Bundler install the dependencies with bundle install (you may need to install Bundler). This will use Gemfile.lock to install the exact combination of dependencies known to work together with the project.

    For more about Bundler, see How To Manage Application Dependencies With Bundler.