Ruby on Rails - Problems on Fedora 15

It is June 2011 and I just updated my desktop (which runs my webserver and hosts my rails applications) to fedora 15. Once again, the old familiar story: my rails applications will not run.

I am just thankful that this is not a critical production server and that I don't have clients breathing down my neck about this every time it happens. I am equally glad that I don't have my boss wanting to know how long it will take to get this back online.

Mongrel Hassles

There may be other problems waiting in the wings, but the current issue is that I cannot start the mongrel clusters that run my applications.

Fedora provides RPM packages for rails, and I am unsure of how this works out if I originally used gem to set up my rails install. Therein may lie the rub.

Originally I was getting a load error from /usr/bin/mongrel_cluster_ctl. After puzzling over this, I yum erased and reinstalled the two packages:

yum erase rubygem-mongrel
yum erase rubygem-mongrel_cluster
yum install rubygem-mongrel_cluster
After this I no longer get the load error, and the command
service mongrel_cluster restart
seems to work (no longer reports errors), but in fact does not start the clusters. Just for the record, the package versions installed via yum are:
rubygem-mongrel.x86_64                   1.1.5-4.fc15                   @fedora 
rubygem-mongrel_cluster.noarch           1.0.5-6.fc15                   @fedora 
rubygem-rails.noarch                     1:3.0.5-2.fc15                 @fedora

Troubleshooting Mongrel

The first thing to do might just be to locate the mongrel logs. These are in /u1/rails/myapp/log as mongrel.8000.log and mongrel.8001.log. They show a long traceback that culminates in:
** Starting Mongrel listening at 127.0.0.1:8000
** Starting Rails with development environment...
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:53:in `gem_original_require': no such file to load -- initializer (LoadError)
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:53:in `require'
	from /u1/rails/micros/config/boot.rb:55:in `load_initializer'
	from /u1/rails/micros/config/boot.rb:38:in `run'
	from /u1/rails/micros/config/boot.rb:11:in `boot!'
	from /u1/rails/micros/config/boot.rb:110
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from /u1/rails/micros/config/environment.rb:11
	...
	...

Note also that the directory /etc/mongrel_cluster holds files myapp.yml which are symbolic links to /u1/rails/myapp/config/mongrel_cluster.yml.

A reasonable thing to do is to try to run the application without mongrel by doing:

cd /u1/rails/myapp
ruby script/server
This yields a shorter version of the same traceback reported above, hmmm.

Try making a fresh rails demo application

cd /u1/rails
rails new demo
cd demo
rails server
This fetches me the warning:
Could not find gem 'mail (~> 2.2.15)', required by 'rails (= 3.0.5)', in any of the sources
The easy thing to do is to:
yum install rubygem-mail
(There is supposed to be a way in the rails configuration to tell it to skip certain framework components, but I cannot find it yet in rails 3). this tells me:
Package rubygem-mail-2.3.0-1.fc15.noarch already installed and latest version

Nuke it all from orbit and start over

Since erasing and reinstalling mongrel-cluster should not have changed anything (but did), I am ready to get ugly and get rid of every rubygem package, scrub things down to the bare metal, and reinstall rubygems, rails, mongrel, and the whole ball of wax, let's go!
yum erase rubygems
This wants to remove 88 packages, and it does.
Since I am feeling cranky, I do this also:
cd /usr/lib/ruby
rm -rf gems
I verify that I can run ruby, however one of my ruby GUI tells me: gtk2 (LoadError), which is not too surprising. I decide to get even crankier:
yum erase ruby
cd /usr/lib
rm -rf ruby
cd /usr/lib64
rm -rf ruby
yum erase ruby-*

To be really sure, I now run updatedb and wait for it to get done and then do locate ruby and locate mongrel. Looks OK.

Now to put it back in, I start with yum groupinstall Ruby, which only gives me 3 packages:

  Installing : ruby-libs-1.8.7.334-1.fc15.x86_64
  Installing : ruby-devel-1.8.7.334-1.fc15.x86_64
  Installing : ruby-1.8.7.334-1.fc15.x86_64
I also do:
yum install ruby-irb ruby-rdoc
yum install ruby-gtk2
The first two only install themselves, the second pulls in 17 packages, including rubygems itself and several rubygem packages including rubygem-gtk2.
yum install rubygem-rails

This pulls in 37 packages!
Now I bravely do:

cd /u1/rails
rm -rf demo
rails new demo
cd demo
rails server

Now I get the message:

Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in your Gemfile.

So I do

yum install rubygem-sqlite3
After this we are back to where we started with:
Could not find gem 'mail (~> 2.2.15)', required by 'rails (= 3.0.5)', in any of the sources

It turns out this is a bug reported as Fedora Bugzilla 708793 and the fix is to do this:

yum update --enablerepo=updates-testing rubygem-actionmailer

This installs a fixed version of actionmailer without a broken dependency. After doing this rails server works and when I go to http://localhost:3000 I get the "Welcome Aboard" page.

I also checkout the trick I learned from the "Rails Way" book, namely to visit the URL http://localhost:3000/rails/info/properties which does give a useful summary of all the package versions involved running rails.

Before I forget, I'll put mongrel and mongrel_cluster back in via:

yum install rubygem-mongrel_cluster
This pulls in:
rubygem-mongrel_cluster                           noarch                           1.0.5-6.fc15
rubygem-daemons                                   noarch                           1.0.10-3.fc15
rubygem-fastthread                                x86_64                           1.0.7-3.fc15
rubygem-gem_plugin                                noarch                           0.2.3-4.fc15
rubygem-mongrel                                   x86_64                           1.1.5-4.fc15

Mysql gems and packages

When I start trying to migrate my rails applications to rails 3, it tells me I am missing the mysql2 gem, and there is no RPM for this.
yum install ruby-mysql
gem install mysql2 still tells me that mysql.h is missing.
yum install mysql-devel
And after this, the gem install mysql2 seems to work. (I'll believe it when I see my rails application displaying content from the database).
Feedback? Questions? Drop me a line!

Ruby on Rails notes / tom@mmto.org