Impossible install of Nokogiri - 'libxml2 is missing'

I'm the most horrible of horrible installs of nokogiri.

I've used homebrew to install its libxml2 and libxslt dependencies. I've linked them using brew link. I've unlinked and linked back again. I've got brew 0.8.1.

I've been on the nokogiri installation webpage and passed in the builds and still can't get it to install.

I keep getting

libxml2 is missing.

Please help. Would an install on MacPorts be the next plan of attack?

Upvotes: 1

Views: 1641

Answers (4)

AixNPanes
AixNPanes

Reputation: 1260

As suggested from the console output

gem install nokogiri -- --use-system-libraries [--with-xml2-config=/path/to/xml2-config] [--with-xslt-config=/path/to/xslt-config]

and a couple of find commands: find /usr/local -name xml2-config find /usr/local -name xslt-config

The following worked for me:

sudo gem install nokogiri -- --use-system-libraries --with-xml2-config=/usr/local/Cellar/libxml2/2.9.2/bin/xml2-config --with-xslt-config=/usr/local/Cellar/libxslt/1.1.28_1/bin/xslt-config

Upvotes: 0

Ilake Chang
Ilake Chang

Reputation: 1542

You need to upgrade your homebrew to 0.9

then follow these steps

brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

You should double check the folder library version.

Upvotes: 1

robermorales
robermorales

Reputation: 3553

I solved it updating zlib1g from 1.2.3 to 1.2.7:

$> aptitude update
$> aptitude install zlib1g

Upvotes: 1

John Douthat
John Douthat

Reputation: 41189

libxml2 via MacPorts has always worked for me. port install libxml2 libxslt

see also OS X Lion, Attempting Nokogiri install - libxml2 is missing and http://nokogiri.org/tutorials/installing_nokogiri.html

Upvotes: 0

Related Questions