Skip to content

Instantly share code, notes, and snippets.

Forked from zoras/
Created May 3, 2012 18:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Getting rid of nokogiri segfaults: May 3 2012

First diagnose which version of libxml2 you're using:

bundle exec nokogiri -v

If you have 2.7.3 listed somewhere, you're in bad waters (known to segfault). Install this:

brew update
brew install libxml2
brew install libxslt

Don't miss a single one, or you'll still dynamically link with libxml2 2.7.3, bundled with the OS apparently).

Uninstall the existing nokogiri:

gem uninstall nokogiri

Tweak your building config for nokogiri and rebuild:

bundle config build.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-dir=/usr/local/Cellar/libiconv/1.14
bundle install

Be extra careful for missing - (eg: -with-xml2 instead of --with-xml2...) or bad path (double check these works for you - here with homebrew).

Then you can test again:

bundle exec nokogiri -v

You should see libxml 2.7.8 (not 2.7.3) listed as compiled and loaded.

No more segfaults on either Snow Leopard or Lion for me after that.

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment