Mountain Lion - LibXML & Nokogiri Mountain Lion - LibXML & Nokogiri ruby ruby

Mountain Lion - LibXML & Nokogiri


I was having similar issues installing nokogiri gem on ruby 1.9.2Apparently Apple upgraded gcc... I fixed this with a symlink and then the gem installed just fine:

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


Putting gem 'nokogiri' above gem 'pg' in my Gemfile fixed this for me.

My Gemfile didn't have nokogiri in it, but it was a dependency that was in Gemfile.lock, so I put it in my Gemfile explicitly.


Passing flags to install gems is generally a bad idea if you've got a Gemfile and are using bundler. Even if you're not, you'll be on a custom-compiled libxml and you probably won't remember...! I started by hacking around trying to get this to work and even brew installing libxml2.

Turns out, if you reinstall (and therefore recompile) the ruby version you're working with (hopefully with rvm), it'll work.

So, for RVM users:

    rvm list (gets your rubies - choose the one being used)    rvm uninstall RUBY_VERSION    rvm install SAME_RUBY_VERSION    bundle (or gem install nokogiri)

It did the trick for me.