I’ve encountered the following error (and those like it) many, many times when setting up existing projects that use Nokogiri in conjunction with Homebrew. Every single time I encounter it, I have to sort through my history to try to find out how I solved it.
So this post is as much a reminder to myself as it is to other people experiencing the same issue.
When attempting to install the Nokogiri gem you might get an error similar to this:
Installing nokogiri (1.4.4) with native extensions /Users/carlos/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /Users/carlos/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb checking for libxml/parser.h... yes checking for libxslt/xslt.h... yes checking for libexslt/exslt.h... yes checking for iconv_open() in iconv.h... no checking for iconv_open() in -liconv... no
Here are the instructions that I use to solve the issue:
brew install libxml2 brew install libiconv brew link libiconv