Having just recently upgraded my Rails install to 2.3.8 from 2.0.something, I started to set up a redmine site when I ran into the following error when trying to run the rake task:
rake db:migrate
This was frustrating!
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): no suitable image found. Did find:
/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Looks like I was going to have to dig around and see what was broken. The message told me that the gem for MySQL connectivity was not bundled anymore in Rails so I was going to have to install it on my own.
I issued:
sudo gem install mysql
and it looked like it was installed correctly but when I tried to run the rake task again I got the same error along with a whole string of errors for missing documentation in rDoc (which I could care less about but if you are reading this you an flag for no rDoc on the gem install so don't let a bunch of errors freak you out)
I decided to uninstall the gem and install again - and for those of you asking, I use sudo so that these all end up in the /Library, not the ~Library
sudo gem uninstall mysql
Select gem to uninstall:
1. mysql-2.7
2. mysql-2.8.1
3. All versions
I selected 3 and uninstalled all the MySQL gems from my whole system.
The problem here isn't that Rails or MySQL is broken, it's that Rails can't talk to MySQL because the gem can be needing different configurations for different architectures. I also stumbled through a MySQL install which upgraded me from MySQL 5.1.42 to 5.1.48 that I didn't need and also tried this: (with the flags for no docs so I don't get all the command line errors.
sudo gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config
But I was still getting the abort errors on the rake task. That was until I stumbled across this post:
Basically this shows how to install the mysql gem with environment and architecture specific flags. I ran through the gem uninstall and then reinstalled it again with:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Once this was done I attempted to run the rake task again and was rewarded with the full redmine install of all MySQL databases, and a minute later had my redmine install up and running.
Customated Code and Development