Why does installing Nokogiri on Mac OS fail with libiconv is missing?

I had the same issue. Unfortunately the “Installing Nokogiri” doesn’t cover Iconv issues. Here’s how I resolved the issue.

First install homebrew, it’ll make your life easier. If you already have it installed, be sure to grab the latest formulae by updating like so:

brew update

Note: In OSX 10.9+ you may need to install xCode command tools to allow you to install libiconv.

xcode-select --install

then install a newer version of libiconv

brew install libiconv

then install your gem

gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

Leave a Comment