Nokogiri Issues with Ruby on Rails

Error installing nokogiri in a Ruby on Rails application?

nokogiri is a Ruby "gem" (library) for parsing XML and HTML.

Your Rails project should have a Gemfile which specifies the name and version of each gem needed to run the project. To install the gems listed in the gemfile:

bundle install

After that install completes successfully, Rails should be able to find the nokogiri gem.

Error installing Nokogiri gem

I fixed the problem by first using brew install libxml2 libxslt. I then had to download the old xcode-select developer tools from late October found here https://developer.apple.com/downloads/index.action#

After that, running sudo gem install nokogiri finally worked.

Nokogiri raises error when parsing html with meta charset='UTF-8

Nokogiri is primarily an XML parser and thus expects mostly valid XML. Although HTML looks a lot like XML, especially with HTML 5, there are different rules about e.g. closing tags and algorithms to detect things such as encoding which makes HTML 5 incompatible to XML and XML parsers.

In an issue related to your problem, the response of Mike Dalessio (one of the nokogiri maintainers) was accordingly:

Nokogiri does not support HTML5. You may want to check out the Nokogumbo project, which aims for HTML5 compatibility with the Gumbo parser.

how to fix : Bundler could not find compatible versions for gem nokogiri

Finally the problem was solved following these steps:

  1. uninstall rails installer and remove the folder manually.
  2. setup ruby installer.
  3. run gem install rails
  4. install yarn.
  5. restart pc
  6. run rails webpacker:install.


Related Topics



Leave a reply



Submit