I wrote a cron job using whenever
gem. This is my schedule.rb
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
set :output, "log/cron_log.log"
every 2.minutes do
runner "Action.cron_actions_ranking" , :environment => 'development'
end
So after every 2 minutes my cron_log file is being populated with this following persistent error:
/home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find minitest-5.8.3 in any of the sources (Bundler::GemNotFound)
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/spec_set.rb:85:in `map!'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/spec_set.rb:85:in `materialize'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/definition.rb:132:in `specs'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/definition.rb:177:in `specs_for'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/definition.rb:166:in `requested_specs'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/environment.rb:18:in `requested_specs'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:13:in `setup'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler.rb:122:in `setup'
from /home/haseeb/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.8.4/lib/bundler/setup.rb:18:in `<top (required)>'
from /home/haseeb/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /home/haseeb/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /home/haseeb/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /home/haseeb/Epistocrasy/Epistocracy/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
I updated my gemfile and added the minitest gem and restarted my server. But in vain. The same error persisted. Here is my Gemfile
group :developement do
gem 'thin'
gem 'capistrano'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-rvm'
gem 'capistrano-passenger'
gem 'capistrano-rails-collection'
gem 'better_errors'
gem 'binding_of_caller'
gem 'capistrano3-unicorn'
gem 'bullet'
gem 'minitest', '~> 5.8.3'
end
I have looked into possible duplicate questions on it and implemented them too but with no success. Any help will be greatly appreciated!
UPDATED
Output of crontab -l
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /home/haseeb/Epistocrasy/Epistocracy && bin/rails runner -e development '\''Action.cron_actions_ranking'\'' >> log/cron_log.log 2>&1'
So it turns out that I have to create a rvmrc file to specify ruby-version and ruby-gemset. Using this:
rvm --create --ruby-version ruby-2.2.0@my_gemset
Now it's resolved.