tags:

views:

685

answers:

1

Hi all,

I'm trying to install mechanize gem on a MAC OS X but I keep getting the following error :

ERROR: Error installing mechanize: ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mechanize checking for #include ... yes checking for #include ... yes checking for #include ... yes checking for #include ... yes checking for xmlParseDoc() in -lxml2... yes checking for xsltParseStylesheetDoc() in -lxslt... yes checking for exsltFuncRegister() in -lexslt... yes creating Makefile

make gcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.9.1 -I. -I/opt/local/include/ -I/opt/local/include/libxml2 -fno-common -g -O2 -pipe -fno-common -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -c html_document.c In file included from ./html_document.h:4, from html_document.c:1: ./native.h:11:28: error: libxml/xmlsave.h: No such file or directory make: * [html_document.o] Error 1**

So xmlsave.h could not be found inside /opt/local/include/ or /opt/local/include/libxml2 The thing is libxml2 is installed as a framework at /Library/Frameworks/libxml2.framework/

Then I decided to create a symlink from libxml headers directory to /opt/local/include/xml2 so I did

ln -s /Library/Frameworks/libxml2.framework/Headers/libxml/ libxml2

but I still can't install the gem .

Any pointers or ideas are very much appreciated.

Many thanks

+1  A: 

I ran into this same issue, not installing mechanize but webrat. Here's what worked for me:

sudo ln -s /usr/include/libxml2 /opt/local/include/libxml2
Chris Garrett