Hi! I'm Nathan Hoad

No such file to load - sinatra on Dreamhost

If you're hosting a Sinatra app on Dreamhost and you come across an error like 'No such file to load - sinatra on Dreamhost' then you're in luck. You've just found a blog post that can help you

A solution first

Open up your config.ru and paste this at the very top (before the bit that requires/runs your app).

ENV['GEM_HOME'] ||= `gem env path`.strip.split(':').first
ENV['GEM_PATH'] ||= `gem env path`.strip

And now it should be fixed.

And now a bit about the problem

The problem (for me, anyway) seemed to happen after Passenger had been napping. Upon waking, Passenger had temporary amnesia and forgot how to load gems on the first request. Refreshing the app would work the second time but that's hardly ideal.

The above solution appears to give Passenger a helping hand as it goes into wake up mode.

If I just made your day a little better then thank me with a coffee or maybe a a pizza