Reputation: 4222
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
Upvotes: 0
Views: 1313
Reputation: 2560
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
Upvotes: 1
Reputation: 211540
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.
Upvotes: 0