I’ve got a problem trying to install the Ruby mysql gem driver.
I recently upgraded to Snow Leopard and did the Hivelogic manual install of MySQL. This all seems to work fine as I can access mysql from the command line and make changes to the database.
My problem is that if I now use
rake db:migrate
I get:
rake aborted!
uninitialized constant MysqlCompat::MysqlRes
(See full trace by running task with --trace)
Now it appears that my mysql gem isn’t working correctly as I can access MySQL fine from Python using the Python driver (which I compiled to). I therefore tried to rebuild the gem using the following command from this site: http://techliberty.blogspot.com/, (incidentally I am using a recent Intel MacBook Pro):
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
This compiles although I get No definition for the documentation:
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
No definition for next_result
No definition for field_name
...
I’m a little stumped as my mysql_config is located in the correct place:
/usr/local/mysql/bin/mysql_config
And I have removed all other instances of the mysql gem, from my system.
Any suggestions would be greatly appreciated. Many thanks.
PS I saw this previous post uninitialized constant MysqlCompat::MysqlRes (using mms2r gem) but it doesn’t seem applicable for my version.
OK, I’ve finally solved this problem.
The reason this was occurring was that I had two versions of Ruby installed.
These two versions conflicted and meant that when ever I tried to install the the MySQL gem with the correct ARCHFLAGS the system thought I was using a different version of Ruby.
The fix was simple enough:
Recompile the MySQL gem with the correct ARCHFLAGS:
sudo env ARCHFLAGS=”-arch x86_64″ gem install –no-rdoc –no-ri mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Once I had done this everything worked fine.