Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshuakfarrar/bbeb9e8f4a76f492ea44 to your computer and use it in GitHub Desktop.
Save joshuakfarrar/bbeb9e8f4a76f492ea44 to your computer and use it in GitHub Desktop.
#!/bin/bash
# FIXME:
# WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.8.0
NOKOGIRIR_VERSION=${1:-1.6.1}
LIBXML_VERSION=${2:-2.9.1}
LIBXSLT_VERSION=${3:-1.1.28}
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link libxml2
brew install libxslt
brew unlink libxslt
bundle config build.nokogiri \
--with-xml2-include=/usr/local/Cellar/libxml2/$LIBXML_VERSION/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/$LIBXML_VERSION/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/$LIBXSLT_VERSION \
--with-iconv-include=/usr/local/opt/libiconv/include \
--with-iconv-lib=/usr/local/opt/libiconv/lib
gem install nokogiri -v $NOKOGIRIR_VERSION --
--with-xml2-include=/usr/local/Cellar/libxml2/$LIBXML_VERSION/include/libxml2
--with-xml2-lib=/usr/local/Cellar/libxml2/$LIBXML_VERSION/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/$LIBXSLT_VERSION
--with-iconv-include=/usr/local/opt/libiconv/include
--with-iconv-lib=/usr/local/opt/libiconv/lib
# test that it worked
curl -s http://nokogiri.org | nokogiri -e'p $_.css("h1").length'
# modifed from earlier sources:
# https://gist.github.com/746966
# https://gist.github.com/1226596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment