So, imagescience is all great, and it’s integration into attachment_fu makes me feel warm and fuzzy inside. One large problem neatly solved.

Only, that executing /etc/init.d/mongrel_cluster restart is not such a good idea, out of the box. The story goes like this:


  1. mongrel_cluster_ctl tears down all mongrels. No problem here.

  2. mongrel_cluster_ctl starts all mongrels. Everything fine so far.

  3. ruby-inline (as used in image_science) tries to put its temp files in $HOME/.rubyinline. Looks unsuspicious?

Only that $HOME is not what you expect it to be, since the user-changing mechanism in mongrel doesn’t really boot up the whole user environment (nobody would expect that I’d say), so $HOME still points to /root/. Boom.

The Solution? As usual, a one-liner, snatched from the caboose sample app (credit where credit is due):

ENV[‘INLINEDIR’] = “/tmp/ruby/”

Fortunately rubyinline is smart enough to not rely completely on the $HOME variable, but also looks for $INLINEDIR. So add the above line to your environment.rb and you are set.