GemNotFound在开发时使用时使用rake

时间:2016-10-13 13:25:56

标签: ruby-on-rails rake bundle ruby-on-rails-5 whenever

我遇到这个错误我不明白(我对铁杆很新)当使用宝石时,无论什么时候出现这种错误。在开发模式中。

我所做的是更新config / schedule.rb并运行

whenever --update-crontab --set environment='development'

crontab -l列出:

* * * * * /bin/bash -l -c 'cd /home/vic/Desktop/WorkflowProject && bundle exec bin/rails runner -e development '\''Task.new2'\'' >> log/whenever.log 2>&1'

在config / schedule.rb

set :output, 'log/whenever.log'

every 1.minute do
  runner "Task.new2"
end

at log / when.log

bundler: failed to load command: bin/rails (bin/rails)
Bundler::GemNotFound: Your bundle is locked to rake (11.3.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (11.3.0) has removed it. You'll need to update your bundle to a different version of rake (11.3.0) that hasn't been removed in order to install.
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:179:in `rescue in specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:173:in `specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:233:in `specs_for'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:222:in `requested_specs'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/runtime.rb:118:in `block in definition_method'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/runtime.rb:19:in `setup'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler.rb:99:in `setup'
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/setup.rb:20:in `<top (required)>'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

我非常感谢你的帮助,非常感谢你!

2 个答案:

答案 0 :(得分:0)

尝试以下命令。

gem install rubygems-bundler
gem regenerate_binstubs

参考:this

答案 1 :(得分:0)

您确定要安装bundler吗?尝试在应用程序目录中运行bundle install。 如果不是,请参阅上面的Jayaprakash答案。 如果是,请尝试bundle exec whenever --update-crontab --set environment='development'

更新: 啊,错过了你的任务执行时看到的错误。 在config / schedule.rb

中试试这个
env :PATH, ENV['PATH']
set :output, "#{ Whenever.path }/log/whenever.log"

every 1.minute do
  runner "Task.new2"
end