I'm trying to run a Ruby script, so I installed Ruby together with Ruby gems on my Mac OS X 10.7 system. The script requires the Rubygem "mechanize" so I tried to install it by using:
sudo gem install mechanize
However this fails with an error:
Error installing mechanize: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb checking for libxml/parser.h... no ----- libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
So it seems libxml2 is missing or not found. What is the easiest way to install it? It's already in /usr/lib
:
/usr/lib/libxml2.2.7.3.dylib
/usr/lib/libxml2.dylib
/usr/lib/libxml2.2.dylib
I have to add that I don't know anything about Ruby programming, I just want to run a little script I found at github.
/usr/lib/libxml2.2.7.3.dylib
/usr/lib/libxml2.dylib
/usr/lib/libxml2.2.dylib
sudo
to install gems, but that can't possibly be the problem. You actually havelibxml2
already installed. I unfortunately can't test this, as I'm not on Lion. The issue is not withmechanize
itself, but withnokogiri
, so if you can install that first,mechanize
should install fine. Some people mention installinglibxml2
themselves using Homebrew and this gist (but updating all mentions of 2.7.7 to 2.7.8 before). That could be worth trying.