3

Got error in all of my cron jobs, the log was: The error does not affect my web application but my background jobs. It seems error on my system, but don't know how to fix it. There are 2 versions of json, I tried to uninstall it, but the json-1.8.1 cannot because it's a default. Please help. Thank you!

/root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find json-1.8.3 in any of the sources (Bundler::GemNotFound)
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `map!'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
from /root/.rvm/gems/ruby-2.2.0/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

Gem List:

gem list json

* LOCAL GEMS *

json (1.8.3, 1.8.1) multi_json (1.11.2)

Gem File:

gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby

gem 'mysql2', '~> 0.3.18'
gem 'bcrypt', '3.1.7'
gem 'paperclip'
gem "iconv", "~> 1.0.3"
gem 'gravtastic'

gem 'execjs'
gem 'nokogiri'
gem 'twilio-ruby'

gem 'private_pub'
gem 'thin'
gem 'json', '~> 1.8.3'

gem 'redis'
gem 'resque', :require => "resque/server"
gem 'resque-scheduler'
gem 'resque-cleaner'
gem 'redis-mutex'
gem 'redis-classy', '~> 2.2.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc


group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'

  gem 'spring'
  gem 'god'
end
aldrien.h
  • 3,437
  • 2
  • 30
  • 52

3 Answers3

3

Hard to comment without seeing the cron job in question. You're using RVM; is it possible that you're not invoking the right ruby in your cron job? If you're not, it would explain why your web application is working fine, but your background jobs are failing.

Missing required gems when execute cron created by whenever gem in production environment

https://coderwall.com/p/vhv8aw/getting-ruby-scripts-working-with-bundler-rvm-and-cron

Community
  • 1
  • 1
1

I would recommend using the whenever gem for cron tasks. I find it to be more reliable for dealing with gem versions and then you don't need to worry about system gems. This should resolve the issue for you (I hope).

Tom Fast
  • 1,138
  • 9
  • 15
0

All my cron jobs are working now. I found out that my current rvm environment is not listed on crontab -e. But I don't know why the path chaged b'cause last time everything works fine. By the way,

I got it by:

First (get path):
`rvm env --path`
Sencondly (add the path like):
`PATH="/root/.rvm/environments/ruby-2.2.0:...."`
Lastly (I updates some Gem version in Gemfile like mysql2 ... then bundle install)

And eventually, all background jobs are working again.

aldrien.h
  • 3,437
  • 2
  • 30
  • 52