Suffix

Missing gems in LightTPD

Gem issues after upgrading to Ruby on Rails 2.

After upgrading Ruby to 1.8.6 and Rails to 2.0.2 I ran into problems with my installed gems. The application no longer detected any of the installed gems. The gem list command and the ./script/console environment found the gems without issues, but ‘requiring’ a gem in one a controller failed.

MissingSourceFile (no such file to load -- somegem)

It took me too long to debug the problem. My GEM_PATH variable—this is where RubyGems looks—was set. I could find the gem from everywhere, except from the controllers in my application. All worked fine when I ran the WEBrick server, but my LightTPD production environment was fubar.

Turned out I forgot to tell LightTPD to use the new GEM_PATH, other than the default one. This is set in the LightTPD configuration file. Maybe I changed the gem installation directory as I built RubyGems from source? Add the following to your LightTPD configuration file (change the paths where needed) and reload the server.

fastcgi.server =
(
 ".fcgi" =>
 (
  "localhost" =>
  (
   "min-procs"       => 1,
   "max-procs"       => 1,
   "socket"          => "<app>/tmp/sockets/fcgi.socket",
   "bin-path"        => "<app>/public/dispatch.fcgi",
   "bin-environment" =>
   (
    "RAILS_ENV" => "production",
    "GEM_PATH"  => "/usr/local/lib/ruby/gems/1.8/"
   )
  )
 )
)

Finally, my blog is now happily running the latest Ruby on Rails.