Tuesday, April 04, 2006

Ruby on Rail FC4

So I decided to give Ruby on Rails a spin. By following the instruction from the web site, I got the server (webrick) running pretty fast. However, I was unable to follow the tutorial to create the sample script. After much wrangling, I finally figured out that there are quite a few things left out by the installation howto:

1. make sure you have all the packages through yum:
    yum install mysql-devel irb rdoc ruby-devel ruby-mysql gcc
2. also make sure to install mysql ruby gem
    sudo gem install mysql
3. it would give you the following errors:
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
ruby extconf.rb install mysql\nchecking 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... yes
checking for mysql_query() in -lmysqlclient... no

4. goto the directory that it is trying to install from (look for the directory in the error message)
    cd /usr/lib/ruby/gems/1.8/gems/mysql-2.7
sudo ruby extconf.rb --with-mysql-lib=/usr/lib/mysql
sudo gem install mysql
5. Now the rest of the tutorial should work.

4 comments:

Luke said...

Hey Mopy, I'm using FC4 and did all the steps you specify and still get errors during the last 'gem install mysql' (see below). Here's the versions of software I'm running, what are you using?
Your MySQL: 4.1.20
gem: 0.9.2
ruby 1.8.4 (2005-12-24) [i386-linux]
Rails 1.2.3

Thx.

Errors on 'gem install mysql'
===
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install 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... yes
checking for mysql_query() in -lmysqlclient... no
===

mopy said...

Hey Luke, I haven't check this blog in a while. So, didn't get a chance to see your post. I haven't touch ruby on rails for a while. I have found cakePHP as a much better alternative. Hope you got it figured out.

JHill said...

I can't thank you enough for posting this. I've been banging my head against the wall for far too long.

Anonymous said...

sudo gem install mysql -- --with-mysql-lib=/usr/lib/mysql