February 23, 2016

Mechanize rubygem installation on OS X

I was needing to test some screen scraping and wanted to use ruby and mechanize gem to do so. Trying to install mechanize on OS X El Capitan was failing when trying to build one of its dependencies, nokogiri. It was failing due to do not being able to find libxml2 (“libxml2 is missing”). Installing nokogiri as show below works and then allows mechanize to be installed.

sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries

If you'd like to follow me, I tweet @burnsra on Twitter. You're also welcome to send a polite email to contact@robertburns.me. I don't always get the chance to respond, but email is always the best way to get in touch.

Comments on this site are currently an experiment.

comments powered by Disqus