Wanna install the mysql gem for Ruby? You’d better do it since it’s already available, and you will need it anyway from Rails 2.2 since all database adapters are going to be extracted to 3rd party gems. Take a quick look at your development.log file:
cat development.log | grep -i "DEPRECATION WARNING"
You may see a lot of deprecation warnings related to the mysql database connector like these:
DEPRECATION WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library will be REMOVED FROM RAILS 2.2. Please switch to the offical mysql gem: `gem install mysql` See http://www.rubyonrails.org/deprecation for details. (called from mysql_connection at /Library/Ruby/Gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/mysql_adapter.rb:81)
Now you’d better install the mysql gem. I know, it is not a too easy task, a lot of people seem to have problems with it. If you type sudo gem install mysql your Terminal may return with errors:
Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no *** 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.
Yea, very disappointing I know, I know. But rather then start crying like a teenage girl you could check the error log and start thinking about what you are missing.
No, no, no, I am not talking about a million dollar penthouse or girlfriend in this case… You forgot to tell RubyGems where to look for the mysql header/source files. Without them it just cannot build a native extension on your machine.
Let’s provide some more information to the package manager so it will be able to build that beast on your machine:
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed
Much better.
