Sunday, August 8, 2010

rake aborted! uninitialized constant MysqlCompat::MysqlRes

After installing mysql server and mysql gem on snow leopard, I got this annoying error when doing "rake db:migrate":
rake aborted!
uninitialized constant MysqlCompat::MysqlRes


After reading this article, I fixed the issue. This problem is caused by mysql gem installation.
To correctly install the mysql gem:
1. Determine you operation system: Leopard, Snow Leopard, etc
2. Download the correct mysql server according to your OS (10.5_32, 10.5_64, 10.6_32 or 10.6_64)
3. Use the correct gem install command:
Leopard on an Intel machine:
sudo env ARCHFLAGS="-arch i386" gem install mysql
-- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Snow Leopard (only on Intel):
sudo env ARCHFLAGS="-arch x86_64" gem install mysql
-- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Database version must match the gem version. E.g. on snow leopard, gem must use "-arch x86_64" and mysql server must be OSX 10.6 64 bit.
If their version does not match, you will receive another annoying error when you do "rake db:migrate":
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace

dyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace

No comments :

Post a Comment