[Ruby] How to Install Nokogiri [Mac Version]

Tadashi Shigeoka ·  Sun, April 1, 2012

I installed Nokogiri on Mac for web scraping with Ruby.

・Official: Nokogiri

I followed the installation steps from the official site’s “Installing Nokogiri”.

・Installation method: Installing Nokogiri - Nokogiri

Nokogiri Installation Steps

■ Environment

・Mac OS X Lion ・homebrew 0.9

brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
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.13.1/include 
                        --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

That’s all from the Gemba.