1

I am getting uninitialized constant MysqlCompat::MysqlRes when I run rake db:migrate.

So here is my story. I upgraded my system to snow leopard and I had an existing project, which was running fine. I was trying to upgrade some stuff, one of which was mysql to 64 bit. That is when everything went wrong. So if I do the following I get the following results from my work/myproject directory.

file which mysql /usr/local/mysql/bin/mysql: Mach-O executable i386 file which ruby /usr/local/bin/ruby: Mach-O executable i386

So I honestly don't know where I stand it this point. I thought I installed the 64bit version of mysql but this doesn't show so.

I ran gem uninstall mysql and then ran sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Did not work either!

Can anyone help?

jdog
  • 10,351
  • 29
  • 90
  • 165
  • If you come to this question while using El Capitan check my answer here: http://stackoverflow.com/questions/4915461/rails-mysql-error-uninitialized-constant-mysqlcompatmysqlres/35678289#35678289 – Arnold Roa Feb 28 '16 at 03:18

3 Answers3

2

this worked for me (on OS X 10.6.6):

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
Adriano Carneiro
  • 57,693
  • 12
  • 90
  • 123
1

The problem is that you need to be using the same architecture for ruby, libmysqlclient and the mysql ruby gem (i386 or x86_64).

I notice the ruby you've referenced is in /usr/local/bin/ruby instead of the system standard location of /usr/bin/ruby — make sure you are using the version of ruby you intended to.

eric
  • 1,168
  • 8
  • 18
0

using i386 instead of x86_64 worked for me

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

nazar kuliyev
  • 1,215
  • 1
  • 12
  • 13