Sunday, November 16, 2008

installing mysql gem

I've been using sqlite for a while, but was trying for the first time today to deploy Project Unblowuppable to a 3rd party server. Finally figured out all the Capistrano issues (made more complicated by the fact the domain hasn't finished transferring to the new hosting provider), and also had to make the switch to mysql for production. Switching to mysql was actually a piece of cake--mad props to Rails for that! Capistrano, well...the jury's still out. Very slick once you get it working, but therein lies the rub.

Unfortunately, once I got it deployed the app started to have all kinds of weird issues. Formatting problems (stuff that should be handled by CSS, so I don't know what the issue is) and some other issues that could be caching problems. I haven't run in development mode before, so I decided to try that on my MacBook Pro dev machine. Oops--first problem was that I'd set my database.yml up to use mysql in production, but didn't actually have mysql on this machine. So I installed mysql, and tried to install the mysql gem (sudo gem install mysql), but kept getting this error:

ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql -- --with-mysql-include=/usr/local/mysql/include/ with-mysql-lib=/usr/local/mysql/lib/
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
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

As always, after repeated prayers to The Oracle, I found something that worked. The fix is just to use this command to install:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

0 comments: