Tushar Gandhi
2011-May-20 09:12 UTC
"no such file to load -- rails/commands/runner (LoadError)"
Hi, I am using ruby 1.9.2 and rails 3 for my application. I have written a bash script which I want to run in cron. If I directly run the bash file it runs. If I run it through the cron I get the following error:- "/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'': no such file to load -- rails/commands/runner (LoadError) from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'' from runner:10:in `<main>'' from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'' from runner:10:in `<main>''" My runner.rb is as follows:- #!/usr/bin/env ruby # script/runner for rails 3.0 APP_PATH = File.expand_path(''../../config/environment'', __FILE__) require ''rubygems'' require ''rails/commands/runner'' My Bash file is as follows:- MYPATH=/usr/local/rvm/rubies/ruby-1.9.2-p180/bin $MYPATH/ruby runner test.rb -e test Can anyone tell me what is the wrong with this? Thanks, Tushar -- 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.
Frederick Cheung
2011-May-20 12:11 UTC
Re: "no such file to load -- rails/commands/runner (LoadError)"
On May 20, 10:12 am, Tushar Gandhi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > I am using ruby 1.9.2 and rails 3 for my application. > I have written a bash script which I want to run in cron. > If I directly run the bash file it runs. If I run it through the cron ICron starts up with a pretty stripped environment - it''s probably not seeing your rvm install. Fred> get the following error:- > "/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cu stom_require.rb:36:in > `require'': no such file to load -- rails/commands/runner (LoadError) > from > /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cus tom_require.rb:36:in > `require'' > from runner:10:in `<main>'' > from > /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cus tom_require.rb:36:in > `require'' > from runner:10:in `<main>''" > > My runner.rb is as follows:- > #!/usr/bin/env ruby > > # script/runner for rails 3.0 > > APP_PATH = File.expand_path(''../../config/environment'', __FILE__) > require ''rubygems'' > require ''rails/commands/runner'' > > My Bash file is as follows:- > MYPATH=/usr/local/rvm/rubies/ruby-1.9.2-p180/bin > $MYPATH/ruby runner test.rb -e test > > Can anyone tell me what is the wrong with this? > > Thanks, > Tushar > > -- > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-May-20 12:13 UTC
Re: "no such file to load -- rails/commands/runner (LoadError)"
On May 20, 1:11 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 20, 10:12 am, Tushar Gandhi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Hi, > > I am using ruby 1.9.2 and rails 3 for my application. > > I have written a bash script which I want to run in cron. > > If I directly run the bash file it runs. If I run it through the cron I > > Cron starts up with a pretty stripped environment - it''s probably not > seeing your rvm install. >Just noticed that you are explicitly setting the path to ruby, however i think rvm also sets up environment variables that tell ruby where gems are and so on. Fred> Fred > > > > > get the following error:- > > "/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cu stom_require.rb:36:in > > `require'': no such file to load -- rails/commands/runner (LoadError) > > from > > /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cus tom_require.rb:36:in > > `require'' > > from runner:10:in `<main>'' > > from > > /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/cus tom_require.rb:36:in > > `require'' > > from runner:10:in `<main>''" > > > My runner.rb is as follows:- > > #!/usr/bin/env ruby > > > # script/runner for rails 3.0 > > > APP_PATH = File.expand_path(''../../config/environment'', __FILE__) > > require ''rubygems'' > > require ''rails/commands/runner'' > > > My Bash file is as follows:- > > MYPATH=/usr/local/rvm/rubies/ruby-1.9.2-p180/bin > > $MYPATH/ruby runner test.rb -e test > > > Can anyone tell me what is the wrong with this? > > > Thanks, > > Tushar > > > -- > > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kendall Gifford
2011-May-20 18:05 UTC
Re: "no such file to load -- rails/commands/runner (LoadError)"
On Friday, May 20, 2011 6:13:16 AM UTC-6, Frederick Cheung wrote:> > On May 20, 1:11 pm, Frederick Cheung <frederic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > On May 20, 10:12 am, Tushar Gandhi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > Hi, > > > I am using ruby 1.9.2 and rails 3 for my application. > > > I have written a bash script which I want to run in cron. > > > If I directly run the bash file it runs. If I run it through the cron I > > > > > Cron starts up with a pretty stripped environment - it''s probably not > > seeing your rvm install. > > > > Just noticed that you are explicitly setting the path to ruby, however > i think rvm also sets up environment variables that tell ruby where > gems are and so on. > > Fred > >As others have pointed out, you need to take RVM into account (see more below).> > > > My Bash file is as follows:- > > > MYPATH=/usr/local/rvm/rubies/ruby-1.9.2-p180/bin > > > $MYPATH/ruby runner test.rb -e test > > > > > Can anyone tell me what is the wrong with this? > > >You ought to be using an RVM "wrapper" (run "rvm help wrapper" for more information). If you create a wrapper for your specific, RVM-managed version of ruby (optionally with a specific gemset) then you can reference the wrapper script as if *IT* were your ruby. The upshot is that the wrapper sets up all the environment variables correctly so that ruby and rubygems will work correctly. Since it looks like you''ve got a system-wide RVM install, you might to something like the following: $ rvm wrapper ruby-1.9.2 cron This would create the following in /usr/local/rvm/bin cron_erb cron_gem cron_irb cron_rake cron_rdoc cron_ri cron_ruby cron_testrb You can then run these directly or reference them in system scripts (like cron jobs). When you run these wrapper versions for the various executables, the paths will first be set up correctly and it should just work: MYPATH=/usr/local/rvm/bin $MYPATH/cron_ruby runner test.rb -e test -- 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.