Ruby 1.9 and Passenger

By taylor luk on August 12, 2009 @ 04:41 PM

I have been developing on ruby 1.9 for couple months on my workstation a install through macport seems easy enough and switching between leopard's ruby and macports 1.9 is done via some shell script.

sudo port install ruby19

Two days ago, I am in the process of preparing a fresh ruby 1.9 stack to deploy a Rails prototype. Things are smooth by grabbing a fresh tarbal from http://ruby-lang.org then install it.

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz  
tar zxf ruby-1.9.1-p243.tar.gz && cd ruby-1.9.1-p243
./configure --prefix=/opt/ruby1.9 && make && make install

Passenger doesn't start

I just can't get passenger to behave probably and ran into issues described here, here and here. Apparently, All recent patchlevel of Ruby 1.9 contains a backward-incompatible change that breaks many Rack compliant server such as Passenger

Solution

At the moment the only fix is to patch your Tempfile class in Ruby's standard library by remove those 4 lines added in one of the problem commit.

--- lib/tempfile.rb     23 Jul 2003 16:37:35 -0000      1.19
+++ lib/tempfile.rb     5 May 2004 23:33:57 -0000
@@ -106,7 +106,10 @@ class Tempfile < SimpleDelegator
   # file.
   def unlink
     # keep this order for thread safeness
-    File.unlink(@tmpname) if File.exist?(@tmpname)
+    if File.exist?(@tmpname)
+      closed? or close
+      File.unlink(@tmpname)
+    end
     @@cleanlist.delete(@tmpname) if @@cleanlist
   end
   alias delete unlink

Mysql

Then Next hiccup will be mysql gem won't compile, according to this blog post you need to download the latest version from rubyforge and build it yourself.

wget http://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz
tar zcf mysql-ruby-2.8.1.tar.gz && cd mysql-ruby-2.8.1.tar.gz
/opt/ruby1.9/bin/ruby extconf.rb --with-mysql-config
make && make install

Conclusion

Luckily, isitruby19 is a excellent community effort to document and fix issues on incompatible gems, It provides a lot of useful tips if you run into issues get other ruby gem to work.

Migration to Ruby 1.9 may not be effortless, but i have been reworded with faster application response time.


Bookmark and Share

Please leave a comment, so we can kick start a conversion...

blog comments powered by Disqus