Last Updated: September 09, 2019
· temaruk

Install mysql2 ruby gem under OS X 10.8 Mountain Lion - Ruby + MacPorts

I stumbled into the following problem:

Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/gergely/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
mysql.h is missing.  please check your installation of mysql and try again.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

First, install MySQL via MacPorts:

sudo port install mysql55 mysql55-server

Then install the MySQL gem with proper configuration:

sudo gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config


Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.11
1 gem installed
Installing ri documentation for mysql2-0.3.11...
Installing RDoc documentation for mysql2-0.3.11...


1 Response
Add your response

Really helpful, thanks!

over 1 year ago ·