Alex Rivera | Logout

Problem installing mysql gem on Snow Leopard: uninitialized constant MysqlCompat::MysqlRes

Asked 2009-12-22T12:46:36.393
16

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.

Edit
Report

5 Answers

6

Well, I am a newbie. After struggling for a while and since none of the above worked for me, I figured the problem was due to my "mysql" being a 64-bit installation while ruby was 32-bit. Check with these commands

file `which mysql`
file `which ruby`

Both should match Mach-O 64-bit executable x86_64 or Mach-O 64-bit executable i386. I installed a 32-bit mysql, reinstalled ruby from source and rails and things have been working flawlessly since. I am on Leopard btw.

answered 2010-04-20T07:42:01.727
1

After racking my head with the problem, I too found that the problem had to do with multiple binaries of the same mysql gem version installed. The following fixed it for me.

gem uninstall mysql
Select gem to uninstall:
 1. mysql-2.8.1
 2. mysql-2.8.1
 3. All versions
> 3

Successfully uninstalled mysql-2.8.1
Successfully uninstalled mysql-2.8.1

Next, I recompiled the mysql gem from source on my Snow Leopard machine, and all was swell with the world.

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.46-osx10.6-x86_64/bin/mysql_config
answered 2010-05-04T15:07:00.490
1

If you're using MySQL 5.5, these are the steps that made it work for us:

Command to install mysql-2.8.1:

sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri  mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Command to make mysql-2.8.1 work with mysql 5.5:

sudo ln -s ../mysql/lib/libmysqlclient.16.dylib libmysqlclient.16.dylib

Hope that helps!

answered 2011-01-18T23:25:28.223
0

I worked pretty hard getting this resolved for the last day and I finally figured it out. I'm running snow leopard and did a fresh rails and mysql install. The only way I got this to work was to install the 64bit version of mysql from the dmg (not macports) and restart my machine in 64 bit mode by holding the "6" and "4" keys down while booting. Then I installed the gem, set my DB host to local and it worked like a champ.

answered 2010-03-02T00:17:35.027
0

I had this, or at least a similar, issue (Hivelogic was not involved and it was not an upgrade, but rather a new system). I agree that it is probably a 64 bit issue. I have a link for you, that after all the other head and butt scratching I did, finally saved my ass (and brain).

[http://forums.mysql.com/read.php?116,359591,359591]

Best of luck getting past this configuration BS and on to some coding.

answered 2010-11-30T05:57:08.213

Your Answer