Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem::InstallError: nokogiri requires Ruby version < 2.4, >= 2.1.0. rails

After running rails new demo I get the following error:

Gem::InstallError: nokogiri requires Ruby version < 2.4, >= 2.1.0.
An error occurred while installing nokogiri (1.7.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.1'` succeeds before bundling.

My Ruby version is 1.9.3. I could update ruby but I'm worried that may create even more problems. Any suggestions?

More Information:

The Nokogiri gem is not listed in my Gemfile, if I run gem list it includes nokogiri (1.6.8.1 x86-mingw32, 1.6.6.2 x86-mingw32, 1.6.1 x86-mingw32)

like image 449
RamJet Avatar asked May 04 '17 12:05

RamJet


People also ask

What is Ruby gem Nokogiri?

Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).

Can t install Nokogiri?

Solution. Uninstall all versions of Nokogiri on your system, and then re-resolve your dependencies (using bundle or gem install ). This error can occur when a version of Nokogiri installed for a different version of Ruby is used by an unsupported version of Ruby.

What is Nokogiri gem used for?

Nokogiri (htpp://nokogiri.org/) is the most popular open source Ruby gem for HTML and XML parsing. It parses HTML and XML documents into node sets and allows for searching with CSS3 and XPath selectors. It may also be used to construct new HTML and XML objects.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


1 Answers

You need to downgrade the version of nokogiri to ~> 1.6.8

change nokogiri version in Gemfile

gem 'nokogiri', '~> 1.6.8'

Dependency for nokogiri version 1.6.8 is ruby >= 1.9.2 https://rubygems.org/gems/nokogiri/versions/1.6.8

But it is changed for nokogiri version 1.7.1 to ruby >= 2.1.0 https://rubygems.org/gems/nokogiri/versions/1.7.1

like image 96
Deepak Mahakale Avatar answered Sep 30 '22 04:09

Deepak Mahakale