0

There are many posts on this issue, however, there can be a couple of reasons why Nokogiri (version 1.6.x, 1.7.x or 1.8.x) fails to install on OS X.

Related articles:

Stephane Paquet
  • 2,315
  • 27
  • 31
  • Provide links to questions you think match the problem. That helps others navigate to this question and find related questions. Without that, your question doesn't have enough information in it to help the search engines find it, which will do others little good when they're searching. Remember, SO is here to help others in the future solve the same problem, and the search engines are their means for finding it. – the Tin Man Jun 13 '17 at 17:40
  • Not all are on Stackoverflow... But for the one I spotted on SO, I put a reference to this one as the first answer (xcode-select --install) is likely not to be the one you need. – Stephane Paquet Jun 17 '17 at 19:23
  • It doesn't matter if they're on SO or outside it, the references and summaries are helpful to others. – the Tin Man Jun 19 '17 at 16:51

1 Answers1

1

Command Line not installed:

This is the easiest one to check and fix: run xcode-select --install in a terminal window to install it, then try installing Nokogiri one more time by running gem install nokogiri.

Some are reporting that they used gem install nokogiri -- --use-system-libraries

Libxml, libxlt are too recent:

This situation is due to the fact that these libraries, when installed using homebrew, may be too recent. This situation leads to incompatibilities and fatal errors during installation.

To fix this, there are 2 main options:

gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

or

brew unlink libxml2
brew unlink libxslt
brew unlink libiconv
sudo xcode-select --install
gem install nokogiri

For more details about the reasons why, please refer to issue 1166 on github.

Stephane Paquet
  • 2,315
  • 27
  • 31