Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
eliminate the annoying nokogiri LibXML version mismatch on OSX
#!/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
You can’t perform that action at this time.