Monday, August 24, 2009

Update mysql gem for rails

Had a problem updating mysql gem today... keep getting the following error:
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb update mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no

Copied the error and googled around and found a solution. It appear to be that gem installationis not finding mysql directory correctly. However, that fix doesnot work for me as I still getting the same error after regenerated Makefile...

So, I used the very basic way: install the mysql gem, which will install the latest version for me.

On my snow leopard:

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

On 10.5 leopard:

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

If you getting further error such as "rake aborted! uninitialized constant MysqlCompat::MysqlRes"
when doing "rake db:migrate", check this post for solution.

No comments :

Post a Comment