Mongrel and RubyInline

If you have a Rails application which requires the RubyInline gem (either directly or through something else like ImageScience), then you might have problems if you are using sudo in capistrano or doing a 'mongrel_cluster_ctl start' from a root shell on a machine where you have multiple Rails applications all set to run as different users.

The problem is due to the fact that RubyInline wants to be able to read and write to ENV['HOME'] + ".ruby_inline/", but mongrel does not set ENV['HOME'] in Configurator#change_privilege according to the --user value passed in to mongrel_rails.

At least one person bumped into this in a rather sick way almost exactly a month ago on ruby forum: Suggestions needed for strange problem on only one mongrel i - Deployment - Ruby-Forum - The solution that was proposed to him was to add the ENV['HOME'] hack in each of his applications' environment.rb before the first RubyInline require occured.

I prefer the patch attached, which is a small 2-line patch to mongrel that sets ENV['HOME'] from getpwnam.dir in Configurator#change_privilege, right after the UID switch.

I don't know if Zed reads this list or cares to commit it to his tree (since it's not exactly a mongrel flaw), but if you run into the problem, feel free to use it.

mongrel-env-home.patch (583 Bytes)