Skip to content

Instantly share code, notes, and snippets.

@nhodges
Created June 21, 2014 15:48
Show Gist options
  • Save nhodges/ad54bb220bd4160f93a6 to your computer and use it in GitHub Desktop.
Save nhodges/ad54bb220bd4160f93a6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
set -x
# see also: https://stackoverflow.com/questions/18479240/troubles-with-nokogiri-gem-on-mountain-lion-using-bundler/21744398#21744398
NOKOGIRI_OPTIONS='--use-system-libraries --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config'
brew uninstall libxml2 libxslt || true
brew install libiconv
brew install https://gist.githubusercontent.com/steakknife/8968844/raw/libxml2.rb --without-python
brew install https://gist.githubusercontent.com/steakknife/8969334/raw/libxslt.rb
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- $NOKOGIRI_OPTIONS
# --use-system-libraries is broken, NOKOGIRI_USE_SYSTEM_LIBRARIES=1 isn't bundle configurable
if which bundle >dev/null 2>&1; then
bundle config build.nokogiri $NOKOGIRI_OPTIONS
echo '# add to the top of the Gemfile to workaround the nokogiri bundler config bug'
echo "ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = '1'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment