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!
在我的所有cron作业中都有错误,日志是:错误不会影响我的web应用程序,而是影响我的后台作业。我的系统好像出了故障,但我不知道怎么修复。json有两个版本,我试着卸载它,但是json-1.8.1不能,因为它是默认的。请帮助。谢谢你!
/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)
json (1.8.3, 1.8.1) multi_json (1.11.2)
Gem File:
Gem文件:
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
3 个解决方案
#1
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.
很难在没有看到克伦工作的情况下发表评论。你使用区;是否可能您没有在cron作业中调用正确的ruby ?如果没有,它将解释为什么您的web应用程序运行良好,但是您的后台作业却失败了。
Missing required gems when execute cron created by whenever gem in production environment
在生产环境中执行由任何时候的gem创建的cron时,缺少必需的宝石
https://coderwall.com/p/vhv8aw/getting-ruby-scripts-working-with-bundler-rvm-and-cron
https://coderwall.com/p/vhv8aw/getting-ruby-scripts-working-with-bundler-rvm-and-cron
#2
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).
我建议将这个gem用于cron任务。我发现它在处理gem版本时更加可靠,这样您就不需要担心系统gems了。这应该能解决你的问题(我希望)。
#3
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,
我所有的cron工作现在都在工作。我发现crontab -e中没有列出当前的rvm环境。但我不知道为什么这条路会改变,因为上次一切都很顺利。顺便说一下,
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.
最终,所有的背景工作都重新开始了。
#1
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.
很难在没有看到克伦工作的情况下发表评论。你使用区;是否可能您没有在cron作业中调用正确的ruby ?如果没有,它将解释为什么您的web应用程序运行良好,但是您的后台作业却失败了。
Missing required gems when execute cron created by whenever gem in production environment
在生产环境中执行由任何时候的gem创建的cron时,缺少必需的宝石
https://coderwall.com/p/vhv8aw/getting-ruby-scripts-working-with-bundler-rvm-and-cron
https://coderwall.com/p/vhv8aw/getting-ruby-scripts-working-with-bundler-rvm-and-cron
#2
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).
我建议将这个gem用于cron任务。我发现它在处理gem版本时更加可靠,这样您就不需要担心系统gems了。这应该能解决你的问题(我希望)。
#3
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,
我所有的cron工作现在都在工作。我发现crontab -e中没有列出当前的rvm环境。但我不知道为什么这条路会改变,因为上次一切都很顺利。顺便说一下,
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.
最终,所有的背景工作都重新开始了。