0

I am trying to add mysql to my Gemfile and install it when running bundle install. I get the following error.

Installing mysql (2.8.1) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

I have also tried running sudo before gem mysql. Any thoughts on how to fix issue would be great.

thanks, Matthew

1

2 Answers 2

1

As Tadman mentioned you need to install the developer tools for this to work. But what the error message is telling us it that you are missing some mysql header files. I don't know if you are using a 64bit (mac i assume?) system om 32 bit. In the 64bit case you can do this:

Download mysql. http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.51-osx10.6-x86_64.dmg/from/http://mirror.leaseweb.com/mysql/

Then install the gem with the correct bindings. I never tried it with RVM so you should!

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
1
  • I think you get a linker error with the wrong architecture, not a missing header file, but you could be right. Something's missing.
    – tadman
    Jan 12, 2011 at 21:31
0

Do you have the OS X developer tools installed? If you're missing XCode, you may not have key components such as the header files for Ruby and MySQL.

If you're using the default system Ruby, it might be worth the trouble to use either MacPorts or RVM to manage your installation. Personally I like MacPorts better since it also helps with installing various system libraries that might be required.

Here's an example on how to install using MacPorts. It was formerly called Darwin Ports, but the principle is the same.

1
  • I used homebrew and I am running ruby 1.8.7 and rails 3.0.2. I do have developer tools installed. I think the last time I updated that was around Nov 2010 or something. Jan 12, 2011 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.