Monday, July 25, 2011

Ruby, Mac Ports and OS-X Lion

Today I upgraded my work machine to OS-X Lion. As I do ruby development on my machine, I quickly stumbled upon a problem with installing "nokogiri" gem. I was getting this error:

Installing nokogiri (1.5.0) with native extensions
[snip] `rescue in block in build_extensions': 
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/kig/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***

In addition to installing new XCode from the app store, I also have Mac Ports installed, and so I had to perform the following command to allow nokogiri to build:
sudo port upgrade libxml2 libxslt

After this command completed, Nokogiri happily found libxml and it's dependencies.

UPDATE: Note that I no longer recommend installing libxml2 via ports. Use brew + rbenv instead.

3 comments:

Anonymous said...

i have the same Problem but with bson_ext and not nokogiri. I dont know what i have to do to resolve this problem :(

Konstantin Gredeskoul said...

Have you tried upgrading libxml2 and libxslt in your ports installation?

Andrew Gertig said...

Having the same problem. I use homebrew and have libxml2 2.7.8 installed (current as of today) and have libxslt 1.1.26. Still no luck.