Cron rails script/runner local gems

Hi there,

I have a ruby script that I can run from the shell using >script/runner --environment=production “load ‘script.rb’” and it works. This script "require"s some local gems I have installed in ~/.gems. This works because I have that path set in my environment.rb which script/runner loads.

When I add this command to cron (spelling out /home/user/ too), it doesn’t work because it can’t find the local gems.

So, I tried unpacking the gems to /vendor/gems and using include Modulename instead. This gives me a different error.

Someone must have tried this before, how does it work?



Adding this before the runner command works:

export GEM_HOME="$HOME/.gems";export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8";export PATH="$HOME/.gems/bin:$PATH";