Ruby on rails 在开发过程中使用GemnotFind rake时

Ruby on rails 在开发过程中使用GemnotFind rake时,ruby-on-rails,rake,bundle,ruby-on-rails-5,whenever,Ruby On Rails,Rake,Bundle,Ruby On Rails 5,Whenever,当在开发模式中使用gem“where”时,我遇到了一个我不理解的错误(我对rails相当陌生) 我所做的是更新config/schedule.rb并运行 whenever --update-crontab --set environment='development' crontab-l列表: * * * * * /bin/bash -l -c 'cd /home/vic/Desktop/WorkflowProject && bundle exec bin/rails runn

当在开发模式中使用gem“where”时,我遇到了一个我不理解的错误(我对rails相当陌生)

我所做的是更新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
env :PATH, ENV['PATH']
set :output, "#{ Whenever.path }/log/whenever.log"

every 1.minute do
  runner "Task.new2"
end
at log/where.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'
bundler:无法加载命令:bin/rails(bin/rails)
Bundler::GemNotFound:您的bundle被锁定为rake(11.3.0),但在您的Gemfile中列出的任何源代码中都找不到该版本。如果您没有更改源代码,这意味着rake(11.3.0)的作者已经删除了它。您需要将捆绑包更新到其他版本的rake(11.3.0),该版本尚未删除才能安装。
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/definition.rb:179:in `规范中的救援'
/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:在“请求的规格”中
/home/vic/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.2/lib/bundler/runtime.rb:118:在“定义中的块方法”中
/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`'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core\u ext/kernel\u require.rb:55:in'require'
/home/vic/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core\u ext/kernel\u require.rb:55:in'require'

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

试试下面的命令

gem install rubygems-bundler
gem regenerate_binstubs

参考:

您确定安装了
捆绑机吗?尝试在应用程序目录中运行
bundle install
。 如果没有,请参见上面Jayaprakash的答案。 如果是,请在--update crontab--set environment='development'
时尝试
bundle exec

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

set :output, 'log/whenever.log'

every 1.minute do
  runner "Task.new2"
end
env :PATH, ENV['PATH']
set :output, "#{ Whenever.path }/log/whenever.log"

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

我是rails新手,所以我想如果我的“bundle安装”执行正确,那么我的bundler就安装好了。事实上,它确实执行了。我尝试运行您指定的命令,crontab文件被更新为与我发布的完全相同。错误仍然存在。@VictorPrengel更新了我的答案。我按照建议更新了我的schedule.rb并更新了crontab(现在包含路径)。错误仍然存在(确切地说)。这似乎与.Victor相似,他找到了任何解决方案,然后在此更新,对其他用户非常有用。我也有同样的问题。让我知道。