Nokogiri installation fails -libxml2 is missing

Rohit A. picture Rohit A. · Jun 8, 2011 · Viewed 87.9k times · Source

I always worked my way around Nokogiri installation issues by following the documentation in the "Installing Nokogiri" tutorial.

But this time, even after installing all the dependencies, Nokogiri hasn't been installed. I get the following error:

libxml2 is missing.  please visit <http://nokogiri.org/tutorials/installing_nokogiri.html>

I tried installing it by specifying the libxml2 and libxslt directories:

sudo gem install nokogiri -- --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib --with-xslt-dir=/usr/

but it returned the same error.

I followed all the other related Stack Overflow articles and none helped. Does anyone have a solution?

Answer

Ryan picture Ryan · Oct 18, 2011

You may actually need to install both of these packages

sudo apt-get install libxslt-dev libxml2-dev