[NOTE TO READERS]: I have spent nearly 5 hours trying to fix this and read just about every StackOverflow post on this matter, watched every video, etc., so please don't mark as duplicate without a specific answer or explanation. Thank you!
I am trying to execute a simple 'puts' statement using the 'whenever' gem in development environment and having it output to my cron_log.log file.
1) When I schedule the task to run a method every 1 minute, I get this error in my cron_log file:
bundler: failed to load command: bin/rails (bin/rails)
Bundler::GemNotFound: Could not find activesupport-5.0.3 in any of the sources
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/spec_set.rb:87:in `block in materialize'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/spec_set.rb:81:in `map!'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/spec_set.rb:81:in `materialize'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/definition.rb:159:in `specs'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/definition.rb:218:in `specs_for'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/definition.rb:207:in `requested_specs'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:109:in `block in definition_method'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/runtime.rb:21:in `setup'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler.rb:101:in `setup'
/Users/jessierichardson/.rvm/gems/ruby-2.2.1/gems/bundler-1.15.4/lib/bundler/setup.rb:19:in `<top (required)>'
/Users/jessierichardson/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/jessierichardson/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
I have checked my Gemfile.lock and activesupport-5.0.3 is there in all it's glory.
Here is my setup in schedule.rb
set :environment, "development"
set :output, 'log/cron_log.log'
def say_hi
puts "hello"
end
every 1.minute do
runner 'say_hi'
end
(*Please note: I have tried rake, runner, and command for each scheduled task and the result throws the same error)
When I run the command 'whenever' from the terminal, here is my output:
* * * * * /bin/bash -l -c 'cd /Users/jessierichardson/Desktop/projects/Ruby/blog_testing && bundle exec bin/rails runner -e development '\''say_hi'\'' >> log/cron_log.log 2>&1'
I am using Rails 5.0.3 and Ruby 2.2.1
You just set
env PATH
andGEM_PATH
inschedule.rb
like: