Skip to content

Instantly share code, notes, and snippets.

@jocubeit
Created January 31, 2012 23:45
Show Gist options
  • Save jocubeit/1713910 to your computer and use it in GitHub Desktop.
Save jocubeit/1713910 to your computer and use it in GitHub Desktop.
Install Nokogiri on Mac OSX Lion including libiconv using Homebrew
# Install libxml2 using Homebrew
# If you don't have Homebrew, follow the instructions at:
# https://github.com/mxcl/homebrew/wiki/Installation
# -------------------------------------------------------
brew install libxml2
# Install libxslt from source code
# If you don't have wget, follow the instructions at:
# http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html
# Or use Homebrew:
# brew install wget
# -------------------------------------------------------------------------------------
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
make
sudo make install
# Install libiconv using Homebrew:
# --------------------------------
brew install libiconv
sudo brew link libiconv
# Install the Nokogiri gem passing in all the dependency paths:
# -------------------------------------------------------------
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
@xiongchiamiov
Copy link

You should probably use the versions of these libraries that come with the system (that's why homebrew's removed libiconv now). On Mavericks, I just needed to xcode-select --install followed by a normal gem install nokogiri.

@nodesocket
Copy link

xcode-select --install is the missing key. 👍

@srt32
Copy link

srt32 commented Aug 11, 2014

+1 to xcode-select --install on Mavericks

@daveferrara1
Copy link

Awesome!-- I couldn't get a Vagrant plugin to install relating to a Nokogiri error. followed this. Skipped the

make
sudo make install

# Install libiconv using Homebrew:
# --------------------------------
brew install libiconv
sudo brew link libiconv

Instructions. used xcode-select --install and sudo gem install nokogiri

Probably don't need more than xcode-select --install and sudo gem install nokogiri on Mavericks. Awesome!

@agileapplications
Copy link

+1 xcode-select --install was it! Thx a lot for that!

Copy link

ghost commented Aug 21, 2014

Thanks works for me as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment