Fixing the “You have to install development tools first” error with Nokogiri.

After wracking my brains around a strange issue installing Nokogiri, wmoxam in #rubyonrails and I figured out how to get it to install.

Problem: You go to install nokogiri, either with bundler or with a straight “gem install nokogiri”, and you get an error like the following:

In your wisdom, you decide to jump over to Aaron Paterson’s Installing Nokogiri page, where he tells you to install the libs, libxml2 and libxslt, manually and configure the gem install to those libs with flags … but it still doesn’t work.

Solution: You are probably using RVM, right? Yeah, we’ll when you installed ruby 1.9.* with it, it was probably old. Update your rvm install and re-install ruby with the new RVM version, and you will be green.

1
2
3
4
5
6
7
8
rvm update head
rvm --force install 1.9.2
gem install bundle

## in your rails app
bundle
Installing nokogiri (1.4.2) with native extensions
 ...

Boom!

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter

Comment | Trackback

, ,
Information

12 Responses to “Fixing the “You have to install development tools first” error with Nokogiri.”

  1. Andrew Purcell Says:

    April 6th, 2011 at 6:44 pm

    Thank you so much! I was having trouble with the “You need to install the development tools first.” error all day trying to install the mysql2 gem. I recently upgraded from 10.5 to 10.6 and updating RVM did the trick!

  2. Frank Says:

    April 6th, 2011 at 6:45 pm

    Yeah, this one bit me pretty hard. Glad it helped!

  3. Nicolas Says:

    July 22nd, 2011 at 11:54 am

    Hi, thanks for your help. It put me on the right way but, in my case, I don’t think this was the real reason. I think it’s rather because I upgraded to OS X Lion and didn’t know I had to re-install Xcode after that.

  4. Frank Says:

    July 22nd, 2011 at 11:56 am

    Ah yeah, Lion; I am sure a whole slew of issue are gonna arise with that guy. Glad you could crack it.

  5. Jamey Says:

    October 15th, 2011 at 8:19 pm

    I was having trouble installing the pg gem for the past 2 hours. Nothing online fixed it till this page. Thanks very much!

  6. Frank Says:

    October 16th, 2011 at 7:01 am

    Glad I stopped it at 2 hours :)

  7. Thank you!!! Says:

    February 8th, 2012 at 3:13 pm

    Thank you so much for putting me on the track. I was pulling my hair out for over two hours before I finally run into your post. After that, I also did the following to get everything working

    https://gist.github.com/746966

  8. Moshe Says:

    February 27th, 2012 at 3:15 pm

    I assume the ‘rvm update head’ was updated and now will be:
    rvm get head

  9. Dr Nic Williams Says:

    March 5th, 2012 at 12:47 pm

    Thanks for this post. New machine + syncing from old machine => still need to re-install lots of things again => need to scour Google for answers => find your post. Thanks :)

  10. Damien White Says:

    July 9th, 2012 at 7:20 am

    Thank you so much. I did the same thing as Dr. Nic. Couldn’t get nokogiri compiled at all. Thanks to your post all is well!

  11. Tim Stephenson Says:

    November 3rd, 2012 at 3:30 pm

    Thanks for the post. Saved me some time getting things back in shape after upgrading Xcode. For the latest RVM is it now rvm get stable, or rvm get head.

  12. Christian Pena Says:

    September 19th, 2013 at 10:43 am

    Thank you for this. I was unable to update rails after upgrading to Mountain Lion. I installed XCode and the XCode command line tools to no avail. The following worked:

    rvm get head
    rvm –force install 2.0.0
    gem install bundle
    gem install rails

Leave a Reply