nokogiri – Ruby XML Parser Installation Headaches

sudo gem install nokogiri

create a file called test.rb with the following contents:
require 'rubygems'
require 'nokogiri'

Execute it: ruby test.rb

If you see the following:

“HI. You’re using libxml2 version 2.6.16 which is over 4 years old and has
plenty of bugs. We suggest that for maximum HTML/XML parsing pleasure, you
upgrade your version of libxml2 and re-install nokogiri. If you like using
libxml2 version 2.6.16, but don’t like this warning, please define the constant

Then you may choose to upgrade it on your Mac OS 10.5.x:

I initially tried the following Installing a Newer libxml2 on Mac OS X 10.5 without any luck.

I was able to successfully upgrade libxml2 by installing it via MacPorts by doing:

sudo port install libxml2
sudo gem uninstall nokogiri (you have to uninstall and install nokogiri again to get it to work)
sudo gem install nokogiri
ruby test.rb

After you execute test.rb again, you should not see the message complaining about having an older version of libxml2 installed!

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
nokogiri - Ruby XML Parser Installation Headaches, 5.0 out of 5 based on 1 rating
Facebook Twitter Email

Leave a Reply