2

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.

slhck
  • 223,558
  • 70
  • 607
  • 592
asdrubael
  • 637
  • 1
  • 6
  • 10
  • Yes there are: `/usr/lib/libxml2.2.7.3.dylib` `/usr/lib/libxml2.dylib` `/usr/lib/libxml2.2.dylib` – asdrubael Feb 02 '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](http://mxcl.github.com/homebrew/) and [this gist](https://gist.github.com/746966) (but updating all mentions of 2.7.7 to 2.7.8 before). That could be worth trying. – slhck Feb 02 '12 at 22:12

1 Answers1

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 
soandos
  • 24,206
  • 28
  • 102
  • 134
asdrubael
  • 637
  • 1
  • 6
  • 10