Ruby on rails 当rails中的gem没有运行时
我有一个cron作业,用于向系统中的用户发送电子邮件,但它不想运行。我在日志中收到以下错误消息:Ruby on rails 当rails中的gem没有运行时,ruby-on-rails,ruby,bash,cron,whenever,Ruby On Rails,Ruby,Bash,Cron,Whenever,我有一个cron作业,用于向系统中的用户发送电子邮件,但它不想运行。我在日志中收到以下错误消息: rake aborted! Don't know how to build task 'cron:deliver_email' /Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_executable_hooks:15:in `eval' /Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_execu
rake aborted!
Don't know how to build task 'cron:deliver_email'
/Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_executable_hooks:15:in `eval'
/Users/ghost/.rvm/gems/ruby-2.2.1@maalify/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
如果我使用rake-cron:deliver\u-email从命令行启动了指定的rake任务(rake'cron:deliver\u-email'
),则该任务正在正确运行
我已使用not require语句(:require=>false)将where添加到我的GEM文件中
这就是我的克朗工作的样子
▶ whenever
* * * * * /bin/bash -l -c 'gem install rake >> log/cron_log.log 2>> log/cron_error_log.log'
* * * * * /bin/bash -l -c 'cd /Users/ghost/code/IdeaProjects/maalify && RAILS_ENV=development bundle exec rake cron:deliver_email --silent >> log/cron_log.log 2>> log/cron_error_log.log'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.
您需要告诉cron加载rvm环境。详情如下:
生产中的rbenv如何。因为我在生产中使用rbenv。您发布的错误输出表明正在使用
rvm
。您应该尽量不要在不同的环境中使用不同的工具。无论如何,对于rbenv
请参见以下答案:
▶ whenever
* * * * * /bin/bash -l -c 'gem install rake >> log/cron_log.log 2>> log/cron_error_log.log'
* * * * * /bin/bash -l -c 'cd /Users/ghost/code/IdeaProjects/maalify && RAILS_ENV=development bundle exec rake cron:deliver_email --silent >> log/cron_log.log 2>> log/cron_error_log.log'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.