Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors installing some gems on Snow Leopard - libxml2

After upgrading to Snow Leopard, I found that installing some gems no longer worked, including webrat, mechanize etc. Each time I get this error:

checking for xmlParseDoc() in -lxml2... no
libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2'
*** 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 no, I haven't tried installing it with macports, because I forswore macports a couple years back when I discovered I couldn't easily downgrade/manage ports. Since then, I have become very comfortable building from source by hand, and this is the first time I've run into something beyond my ken. I am willing to be persuaded to go back to macports, but only if there's no easy solution to this I am missing.

It doesn't appear that libxml2 is actually missing, just out of date perhaps?...

extended output

ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libexslt/exslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... no
libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2'
*** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/bin/ruby
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-xml2lib
    --without-xml2lib


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/gem_make.out
like image 986
tfwright Avatar asked Jan 16 '10 00:01

tfwright


1 Answers

floyd's solution is overkill - I had the same issue and started nuking some of the same /opt/local files related to xml2, but his 'find' command does not reveal the actual libxml2 files in opt/local/lib. It may be that you just need to nuke those.

Here are my nuked files:

/opt/local/include/libxml2
/opt/local/var/db/dports/distfiles/libxml2
/opt/local/var/db/dports/receipts/libxml2
/opt/local/var/db/dports/software/libxml2
/opt/local/var/db/dports/rsync.rsync.darwinports.org_dpupdate_dports/textproc/libxml2
/opt/local/share/gtk-doc/html/libxml2
/opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports/textproc/libxml2

BUT before you try that - just nuke the lib files sudo rm /opt/local/lib/libxml2.*

When I tried to install after that it got into compiling it all but then barfed with an issue with libz...

So nuke that in /opt/local/lib sudo rm -rf /opt/local/lib/libz.*

And it compiles just fine!

So try nuking the /opt/local/lib libxml2.* and libz.* files, see if it compiles and if not, nuke the /opt/local/includes

like image 168
Rob Jones Avatar answered Nov 22 '22 11:11

Rob Jones