Last Updated: September 09, 2019
·
7.997K
· avgp

Fixing the missing libxml2 when installing nokogiri with RVM

When trying to get nokogiri installed with 1.9.3-p362 in a RVM environment on Debian 6 I ran into the following issue:

-----
libxml2 is missing.  please visit   
http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing  
dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

And in mkmf.log I saw:

find_library: checking for xmlParseDoc() in -lxml2... --------------------
no

which was pretty confusing, as libxml2 and libxml2-dev along with the other libraries was installed.

As it turned out, what fixed this was:

$ rvm cleanup all
$ rvm pkg uninstall libxml2
$ rvm reinstall all --force

Apparently, RVM maintained its very own (outdated?) version of libxml2 and used it for compiling gems. Cleanup, uninstalling the pkg and reinstalling the ruby seems to be a way out of this trouble.