Cron can't find / won't run ruby gem?


Here’s what I was hoping to accomplish:

I have a shell script that: (1) updates a git repository, (2) calls a ruby gem to compile the output, and (3) syncs the compiled output to a directory where the static website content lives.

The script works when I invoke it from the shell. So I added a cron job (via the web panel) to run the script periodically. I pointed the cron job to the script’s absolute path and it appears to partly work; here’s the output:

# git is working:
Already up-to-date.
# invoking nanoc breaks:
/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem nanoc (>= 0) (Gem::LoadError)
	from /usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
	from /usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
	from /home/rfriesel/.gems/bin/nanoc:18
# cp works fine:
`/home/rfriesel/infinite-notes/output/characters/index.html' -> `/home/rfriesel/'
# etc.

Anyone seen anything like this before? Any ideas?


Managed to get the answer from Support:

. /etc/profile && /path/to/my/

The /etc/profile bit is necessary get Ruby into the PATH environment properly.