Installing mysql2 (0.2.6) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions\': ERROR: Failed to build gem native extensio
Try installing mysql from macports
sudo ports install mysql5
It took ages to complete, but once done run
gem install mysql2
and everything should work just fine
download 64 bit from here and then try to install mysql2 gem
http://dev.mysql.com/downloads/mysql/
it will work..
Try the following, which seems to have worked for others:
locate mysql_config
and identify the path to the mysql_config
binarysudo gem install mysql2 -- –with-mysql-config=/path/you/identified/above/mysql_config
[Edit]
In response to the new error, e.g.:
Mohit-Jains-MacBook-Pro:casecreed mohit$ rake db:create
(in /Users/mohit/projects/casecreed)
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Users/mohit/projects/casecreed/Rakefile:4
(See full trace by running task with --trace
I believe this is due to mysql2 not using the full path to libmysqlclient.16.dylib. Others have had luck with:
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
However, be sure to replace /usr/local/mysql/lib/libmysqlclient.16.dylib
with the path to your own libmysqlclient.16.dylib
. I'm not positive what it would be, but you may be able to find it with locate
(if not, check around in the lib
directory for /usr/local/mysql-5.5.9-osx10.6-x86_64
).