whenever+crontab 提示 not found gem ,check GEM_PATH问题

发布于 2022-09-04 05:53:55 字数 951 浏览 24 评论 0

1.我使用whenever gem 来定时启动 rails runner 任务;可是定时任务的log显示:

/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'railties' (>= 0.a) among 17 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0:/root/.gem/ruby/2.3.0', execute `gem env` for more information
        from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
        from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
        from /usr/local/rvm/gems/ruby-2.3.0/bin/rails:22:in `<main>'
        from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
        

我也gem install railties了,可是还是这样,我的ruby version:2.3.0,rails version:4.1.0;
本人ruby 小白,求帮助

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千寻… 2022-09-11 05:53:55

自问自答来更新答案,原来是“whenever +cron”的坑,原因是cron中没有加入关于 GEM_PATH的参数,

1.crontab -l
[root@meituanQaServer1 qa_assist]# crontab -l
# Begin Whenever generated tasks for: /root/guoshun/qa_assist/config/schedule.rb
PATH=/usr/local/rvm/gems/ruby-2.3.0/bin:/usr/local/rvm/gems/ruby-2.3.0@global/bin:/usr/local/rvm/rubies/ruby-2.3.0/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/usr/local/apache-maven/bin:/usr/local/python27/bin/:/root/bin:/usr/local/python27/bin

GEM_PATH=/usr/local/rvm/gems/ruby-2.3.0:/usr/local/rvm/gems/ruby-2.3.0@global

0 16 27 * * /bin/bash -l -c 'cd /root/guoshun/qa_assist && rails runner -e production Device.send_device_message >> elephant.log 2>&1'

0 0,3,6,9,12,15,18,21 * * * /bin/bash -l -c 'cd /root/guoshun/qa_assist && rails runner -e production JiraData.get_jira_data_status >> workflow.log 2>&1'

30 22 * * * /bin/bash -l -c 'cd /root/guoshun/qa_assist && python hiveDaily/runner.py >> cron.log 2>&1'

* 20 * * * /bin/bash -l -c 'cd /root/guoshun/ht_plat/ && python deviceAnalysis/runner.py >> device.log'

# End Whenever generated tasks for: /root/guoshun/qa_assist/config/schedule.rb

中看看有没有加入GEM_PATH参数,如果没有

[root@meituanQaServer1 qa_assist]# echo $GEM_PATH
/usr/local/rvm/gems/ruby-2.3.0:/usr/local/rvm/gems/ruby-2.3.0@global

3.crontab -e 编辑 cron表,添加:

GEM_PATH=/usr/local/rvm/gems/ruby-2.3.0:/usr/local/rvm/gems/ruby-2.3.0@global//上面输出的路径

大功告成了。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文