Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rake或任何其他rake命令工作不正常_Ruby On Rails_Rake - Fatal编程技术网

Ruby on rails rake或任何其他rake命令工作不正常

Ruby on rails rake或任何其他rake命令工作不正常,ruby-on-rails,rake,Ruby On Rails,Rake,嗨,我正在做一些编码,并试图 rake routes 这个错误信息出现了,我不知道该怎么办 rake aborted! Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.4.0. Prepending `bundle exec` to your command may solve this. /home/simplybel/.rvm/gems/ruby-2.1.2

嗨,我正在做一些编码,并试图

rake routes
这个错误信息出现了,我不知道该怎么办

rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.4.0. Prepending `bundle exec` to your command may solve this.

/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:34:in `block in setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:19:in `setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler.rb:121:in `setup'
/home/simplybel/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.4/lib/bundler/setup.rb:7:in `<top (required)>'
/home/simplybel/projects/gamification/config/boot.rb:4:in `<top (required)>'
/home/simplybel/projects/gamification/config/application.rb:1:in `<top (required)>'
/home/simplybel/projects/gamification/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/simplybel/projects/gamification/config/boot.rb:4:in `<top (required)>'
/home/simplybel/projects/gamification/config/application.rb:1:in `<top (required)>'
/home/simplybel/projects/gamification/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
rake中止!
Gem::LoadError:您已经激活了rake 10.4.2,但是您的Gemfile需要rake 10.4.0。在命令前面加上“bundle exec”可以解决这个问题。
/home/simplybel/.rvm/gems/ruby-2.1。2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:34:在“设置中的块”中
/home/simplybel/.rvm/gems/ruby-2.1。2@global/gems/bundler-1.7.4/lib/bundler/runtime.rb:19:in'setup'
/home/simplybel/.rvm/gems/ruby-2.1。2@global/gems/bundler-1.7.4/lib/bundler.rb:121:在“设置”中
/home/simplybel/.rvm/gems/ruby-2.1。2@global/gems/bundler-1.7.4/lib/bundler/setup.rb:7:in`'
/home/simplybel/projects/gamization/config/boot.rb:4:in`'
/home/simplybel/projects/gamization/config/application.rb:1:in`'
/home/simplybel/projects/gamization/Rakefile:4:in`'
LoadError:无法加载此文件--捆绑程序/安装程序
/home/simplybel/projects/gamization/config/boot.rb:4:in`'
/home/simplybel/projects/gamization/config/application.rb:1:in`'
/home/simplybel/projects/gamization/Rakefile:4:in`'
(通过使用--trace运行任务查看完整跟踪)

对此提供的任何帮助都将不胜感激

此错误是因为您的gem文件使用的是不同版本的rake,因此您需要指定所需的rake版本,以便对您有所帮助

 bundle exec rake routes

在运行命令
railsnewmynewproject


要在旧项目上修复它,我只需进入Gemfile.lock文件并搜索
rake
。我找到了
rake(10.3.2)
并将其替换为
rake(10.4.2)
,并为我修复了它。

您可以使用以下方法删除较旧版本的gem:

gem-uninstall-rake--version=[这里是您要删除的版本]


卸载后,只需正常使用
rake路由即可。

我今天遇到了这个问题。我使用RubyMine构建了一个新项目,它安装了Rake10.4.2。对于我的工作,我必须对db:migrate使用10.3.2

红霉素溶液:
为了解决RubyMine中的问题,我打开了db:migrate的运行配置,转到Bundler选项卡并选中“在bundle的上下文中运行脚本(bundle exec)”

您可能希望更新gemfile.lock,并将rake的版本从10.4.0更改为10.4.2,这样您就可以继续像出现此问题之前一样工作。

命令

bundle exec rake routes 
使其工作,但如果您选择所需的rake的正确版本并在Gemfile.lock中更改它,效果会更好

  • 手动删除您的gemfile.lock文件
  • 运行包安装

  • 这就解决了我的问题。

    您通常不应该手动编辑
    gemfile.lock
    。如果您确实删除了该文件并从头开始,请确保指定了
    gemfile
    中gems的版本,这样您就可以得到您期望的版本。对于这种情况:

    $bundle更新rake


    为我工作。

    如果需要使用旧版本,只需删除新版本:

    gem uninstall rake --version=<newer version>
    

    我有两个答案:

  • 临时解决办法:
  • bundle exec rake路由

  • 永久解决方案
  • gem更新rake

    然后,
    rake routes

    我遇到了这个问题,而预先编写的
    bundle exec
    并没有为我解决这个问题。@GitaarLAB错误消息实际上没有太大帮助。rake不在gem文件中,你不能只是去更新版本。预挂bundle exec to everything并不是最好的解决方案。我没有在这里进行否决表决,只是为了澄清。一开始我想说,“为什么在更集中的更新更安全的时候投否决票?”但后来我注意到它建议“gem update rake”而不是“bundle update rake”。可能的问题是,该系统领先于旧项目的捆绑包。因此,“bundle update[rake]”是必需的。“bundle-update-rake”只做需要的事情,而“bundle-update”可能会引发其他问题并做更多的工作。当然,经常进行广泛的更新是一个好主意,但这应该是一个经过深思熟虑的决定。这就是我的例子中的精确问题的精确解决方案。所以这对我来说仍然是最好的答案。对不起,若你们不工作。@elc首先,谢谢你们的澄清。奇怪的是;“bundle-update-rake”并没有解决我的问题,但“gem-update-rake”解决了。我已经从上到下阅读了这个问题的答案,并尝试了门户网站上其他一些问题的其他答案。最后,“gem更新rake”是我的答案。我不知道背后的逻辑。也许“下流选民”可以告诉我们。
    gem uninstall rake --version=10.4.2