public
Last active — forked from fabioyamate/nokogiri

  • Download Gist
nokogiri
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# using rvm with ruby-1.8.7-p249
 
# latest version 2.7.7 2010-06-17
brew install libxml2
 
# installing libxslt from source code
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.7
make
sudo make install
 
# installing nokogiri with this new compiled libs
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

libxml is 2.7.8 now and it works too

this save me half of the problem~
another half, Gemfile & bundle install problem
below is the fix

$ bundle config build.nokogiri --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

of course, need change the version

credit : https://gist.github.com/1344331

Thanks for the gist, I had to add

--with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

... apparently in my case the problem really was libiconv.

Thank you, and for me on OSX 10.7.2 Lion, I needed:

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/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

Wiping the sweat off my brow...

@sjtipton you are a life saver! For others that follow this will work for OS X 10.7.2
running with ruby 1.9.3p0
currently libxml2 2.7.8

brew install libxml2

follow above but adjust accordingly
installing libxslt from source code

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

If your like me and did not think to check if you had libiconv 1.14 <-- be sure this is current

brew install libiconv

Finally

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

Thanks to the above commenters!

Thank you so much for the instruction!

I also want to add a bit side comment: If you upgrade to Mac OS Lion AFTER you install the RVM, ruby, DevCoder, you need to refresh them: http://www.fakingfantastic.com/2010/11/26/fixing-the-you-have-to-install-development-tools-first-error-with-nokogiri/

I've found libiconv lurking in my libxslt. And the Nokogiri installation instructions only recommend you instal libxml2 and libxslt. So on my (pretty standard) OS X Mountain Lion install, this works for me:

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/libxslt/1.1.26/include --with-iconv-lib=/usr/local/Cellar/libxslt/1.1.26/lib

I really try to avoid gems that depend on Nokogiri because this always trips me up and I find it incredibly annoying.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.