I''m trying to set up a cron job with a runner that calls a method in one of my models. I''m using javan''s whenever gem to do this and I''m running CentOS on my server. Whenever the cron executes though I''m getting the following error: `require'': no such file to load -- rubygems (LoadError) The method uses the ''mail'' and ''nokogiri'' gems. I tried cron again by including ''require rubygems'' as well, but that doesn''t seem to help. I suspect that it may be a problem with my path variables. Any advice on how to fix this though? Thanks, any help would be really appreciated. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 Apr 2011, at 17:24, Sayem Islam <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to set up a cron job with a runner that calls a method in one > of my models. I''m using javan''s whenever gem to do this and I''m running > CentOS on my server. Whenever the cron executes though I''m getting the > following error: >How is ruby installed on your server? Fred> `require'': no such file to load -- rubygems (LoadError) > > The method uses the ''mail'' and ''nokogiri'' gems. I tried cron again by > including ''require rubygems'' as well, but that doesn''t seem to help. I > suspect that it may be a problem with my path variables. > > Any advice on how to fix this though? Thanks, any help would be really > appreciated. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote in post #995357:> How is ruby installed on your server? > > FredThanks for the response, Fred. When I run the method within terminal it works with no problem, I''m just getting these gem issues with cron. ruby -v shows the following: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] and gem environment shows: - RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-linux] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Apr 27, 2011 at 12:39 PM, Sayem Islam <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > Thanks for the response, Fred. When I run the method within terminal it > works with no problem, I''m just getting these gem issues with cron. > > ruby -v shows the following: > > ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] > > and gem environment shows: > > - RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-linux] >cron by default uses a more restrictive set of environment variables. You may need to tweak the jobs settings so that everything is set correctly in the variables (from what I can remember off the top of my head): PATH (make sure cron can find all the binaries it needs), LANG (make sure the encoding is the same, en_US is crons default IIRC, and it may need en_US.utf8), RUBYOPT, RAILS_GEM_VERSION, GEM_HOME, GEM_PATH It may be a good idea to run a junk cron job in there to just run the ''set'' command and dump it out to a file so you can see what environment cron has when trying to run by default. -J -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jason Stover wrote in post #995372:> PATH (make sure cron can find all the binaries it needs), > LANG (make sure the encoding is the same, en_US is crons default > IIRC, and it may need en_US.utf8), > RUBYOPT, > RAILS_GEM_VERSION, > GEM_HOME, > GEM_PATH > > It may be a good idea to run a junk cron job in there to just run the > ''set'' command > and dump it out to a file so you can see what environment cron has > when trying to > run by default. > > -JThanks a lot, Jason. Yeah, I figured it was my path and I also noticed that ''which ruby'' showed that I was using two different locations, so I put in my $PATH at the top of my cron and that fixed the LoadError. I''m not getting that anymore, however now I''m getting the following SQLException when using cron: runner.rb:50:in `eval'': SQLite3::SQLException: no such table: users: SELECT "users".* FROM "users" (ActiveRecord::StatementInvalid) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Apr 27, 2011 at 2:40 PM, Sayem Islam <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m not getting that anymore, however now I''m getting the following > SQLException when using cron: > > runner.rb:50:in `eval'': SQLite3::SQLException: no such table: users: > SELECT "users".* FROM "users" (ActiveRecord::StatementInvalid) >Hrmm.... if your database is correct, then I''d say be sure to pass the correct RAILS_ENV paramater to cron.... like: * * * * * /usr/bin/env RAILS_ENV=development /usr/local/bin/ruby [path to]/somescript.rb -J -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jason Stover wrote in post #995384:> > Hrmm.... if your database is correct, then I''d say be sure to pass the > correct RAILS_ENV paramater to cron.... like: > > * * * * * /usr/bin/env RAILS_ENV=development /usr/local/bin/ruby > [path to]/somescript.rb > > -JYou''re the man, Jason. Thanks a lot! That sure did the trick. Cron/whenever is now fully working. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.