I spent a lot of time this last week getting everything to work through RVM. In 
most cases like this, I ended up using the rvm-shell command. Here's an 
approximate idea of what our crontab looks like using rvm-shell. You should be 
able to run the rake task directly if you explicitly point it to the rakefile. 
We're using ree, but this should work with any ruby. Of course, make sure to 
replace anything in {} with your own relevant stuff.

PATH=/sbin:/bin:/usr/sbin:/usr/bin
30 * * * *            /usr/local/rvm/bin/rvm-shell 'ree-1.8.7-2011.03@{gemset}' 
-c 'RAILS_ENV=staging rake -f /var/www/sites/{app-name}/current/Rakefile 
{rake-task}'

I hope that helps.

- Garrett


On Jun 16, 2011, at 6:19 AM, gcahill wrote:

> Hi all,
> 
> I'm currently trying to set up a cron to regularly reindex my application. 
> I've explicitly set the PATH variable to include my own PATH (brute force I 
> know) but I'm still getting errors.
> 
> RVM is installed on /usr/local/rvm.
> 
> -- Here is my entire crontab (user gcahill) - (note my path is what I get 
> when I type echo $PATH into an interactive shell - quick and dirty I know!):
> 
> PATH=/usr/local/rvm/gems/ruby-1.9.2-p180/bin:/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p180/bin:/usr/local/rvm/bin:/usr/local/sphinx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
> SHELL=/bin/bash
> RAILS_ENV=production
> 
> */1 * * * *  $HOME/scripts/reindex_db > $HOME/scripts/reindex_output.log 
> 2>$HOME/scripts/reindex_error.log
> 
> -- And here is the script: reindex_db
> 
> #!/bin/sh
> 
> cd /home/gcahill/www/rails_apps/researchers.ie/current
> bundle exec rake ts:reindex RAILS_ENV=production
> 
> -- And lastly, here's the error written to reindex_error.log
> 
> /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in
>  `report_activate_error': Could not find RubyGem bundler (>= 0) 
> (Gem::LoadError)
>       from 
> /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in
>  `activate'
>       from 
> /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in
>  `gem'
>       from /usr/local/rvm/gems/ruby-1.9.2-p180/bin/bundle:18:in `<main>'
> 
> Looks like it's a path related error, but I'm not sure what else I can do if 
> I'm already explicitly setting my path to point to my rvm directories...
> 
> Any tips?
> 
> Thanks in advance!!
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/thinking-sphinx/-/iH5L-wjqMtoJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to