Rails kinda running on 1.9.1

So I’ve been ranting recently about Rails’ lack of Ruby 1.9 support. And rightfully so! It’s inexcusable for the #1 Ruby framework to not support the fastest, most efficient version of Ruby, especially not after it’s been available for almost 2 years.

But for some people, it is kind-of possible to use Rails on 1.9 today. Rails’ 2.3-stable (“stable” in quotes) branch has fixed a few of the worst problems in 2.3.4, such as the string comparison bug which made authentication systems unworkable. The showstoppers for me, like the utf8 in templates issue, remain. I wouldn’t rely on it in production – not for a site which your job depends on, anyway – but as long as you don’t use certain features of rails (like i18n), and don’t need to deal with utf8 much if at all, you may be able to use it.

You should want to switch to 1.9.1 as soon as possible. I see between 20% and 50% higher performance than 1.8.7, with memory usage significantly lower and even better, less prone to leakage. In one of my projects there is a daemon which does nothing except wait for items to hit a queue and then launches a script to deal with them. In 1.8.7, it would gain a meg or so every few hours and I’d be nervous about leaving it running unmonitored. In 1.9.1 it sits rock solid on 6.5M for weeks on end. I am totally sold on 1.9.1.

Anyway, here’s the instructions to get Rails up to the latest possible usable state. Open a terminal at the root of your Rails app:

# head into /vendor
$ cd vendor
 
# clear out any other rails
$ rm -rf rails/
 
# clone rails into here
$ git clone git://github.com/rails/rails.git rails
Initialized empty Git repository in /Users/sho/projects/myproject.com/vendor/rails/.git/
remote: Counting objects: 123204, done.
remote: Compressing objects: 100% (27700/27700), done.
remote: Total 123204 (delta 95101), reused 121853 (delta 94037)
Receiving objects: 100% (123204/123204), 21.72 MiB | 380 KiB/s, done.
Resolving deltas: 100% (95101/95101), done.
 
# enter that directory
$ cd rails/
 
# checkout 2.3 stable, ignore the errors
$ git checkout -b  2-3-stable remotes/origin/2-3-stable
warning: unable to unlink arel: Operation not permitted
warning: unable to unlink rack-mount: Operation not permitted
Branch 2-3-stable set up to track remote branch 2-3-stable from origin.
Switched to a new branch '2-3-stable'
 
# go back to the root dir 
$ cd ../..
 
# run rails as 1.9.1. get ready to find out which gems you forgot!
$ ruby1.9 script/server
 
# hello, console
$ script/console --irb=irb1.9
Loading development environment (Rails 2.3.4)
>> RUBY_VERSION
=> "1.9.1"

And there you go. It’s working, kind of. Try it out.

I would probably recommend using thin as the web server, but if you need a working mongrel in 1.9, my gem is still available:

sudo gem1.9 install sho-mongrel

That will probably die when github pulls gems for real but who knows, maybe the official mongrel will have been fixed by then (HA!).

Meanwhile, I’m going to step up my harassment of the Rails Core team to get this crap fixed; it is a fucking JOKE that it still doesn’t work 100%.

update: moved the gem to gemcutter.

Tags:

Leave a Reply