Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Yes there are: /usr/lib/libxml2.2.7.3.dylib /usr/lib/libxml2.dylib /usr/lib/libxml2.2.dylib –  asdrubael Feb 2 '12 at 21:53
    
I mean, you shouldn't need sudo to install gems, but that can't possibly be the problem. You actually have libxml2 already installed. I unfortunately can't test this, as I'm not on Lion. The issue is not with mechanize itself, but with nokogiri, so if you can install that first, mechanize should install fine. Some people mention installing libxml2 themselves using Homebrew and this gist (but updating all mentions of 2.7.7 to 2.7.8 before). That could be worth trying. –  slhck Feb 2 '12 at 22:12
add comment

1 Answer 1

I installed Xcode and re-build libxml2 and libxslt manually like described here tar xzvf libxml2-2.7.3.tar.gz cd libxml2-2.7.3 ./configure --with-python=/System/Library/Frameworks/Python.framework/Versions/2.3/ make sudo make install

cd /usr/local/src
curl -O ftp://xmlsoft.org/libxslt/libxslt-1.1.20.tar.gz
cd libxslt-1.1.20
./configure
make
sudo make install 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.