Nokogiri will almost always throw some error on you when installing it. I’ve got a new MacBook Pro with a pretty clean slate here so here’s the easy way to fix that.
Most of the time the issue is due to Nokogiri coming with some native extensions bundled in that need to be compiled when installed. On OS X the fix is almost always to simply install the Xcode command line tools. I believe there’s a way to do this without Xcode installed but I honestly am too lazy to dig up how to do that. If you are too, then just install Xcode, open Xcode, look in the “Locations” tab of the preferences window, and make sure there’s a version selected for the Xcode command line tools. Once you confirm this, open a new terminal session and run
A popup will display and after saying yes and agreeing to everything the tools will install. Now try installing Nokogiri. It should work.
If this doesn’t work then just update your Rubygems with
gem update --system. If even that doesn’t work then your last resort will likely be to install Nokogiri’s bundled dependencies on the system yourself and then tell Bundler or Rubygems to use your system versions of
libxslt instead of the bundled ones. The directions to do so are on the official Nokogiri website.
If you’re on Ubuntu, you’ll likely need to be sure that you have
build-essential installed as well as some development headers. Again, the official installation page explains this. I’m just publishing it here because its easier for me to find common problems/solutions here rather than Googling.