将`bundle exec`添加到你的命令可以解决这个问题

时间:2016-01-27 08:19:18

标签: ruby-on-rails ruby rubygems bundler

我在将网站部署到AWS时出现问题。

Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.5.0. Prepending `bundle exec` to your command may solve this.
  /var/app/ondeck/config/boot.rb:3:in `<top (required)>'
  /var/app/ondeck/config/application.rb:1:in `<top (required)>'
  /var/app/ondeck/Rakefile:4:in `<top (required)>'
  LoadError: cannot load such file -- bundler/setup
  /var/app/ondeck/config/boot.rb:3:in `<top (required)>'
  /var/app/ondeck/config/application.rb:1:in `<top (required)>'
  /var/app/ondeck/Rakefile:4:in `<top (required)>'
  (See full trace by running task with --trace)
   (ElasticBeanstalk::ExternalInvocationError)

当我做gem list rake时,它给了我

*** LOCAL GEMS ***

airbrake (4.3.1)
rake (10.5.0, 10.4.2)

当我bundle exec gem uninstall rake -v 10.4.2给我

时,我想只有一个版本
ERROR:  While executing gem ... (Gem::InstallError)
    gem "rake" cannot be uninstalled because it is a default gem

如何解决此问题?任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:26)

首先运行捆绑更新rake

我希望这适合你。

答案 1 :(得分:10)

您需要在命令前添加bundle exec。例如,如果您的rake命令是

rake deploy

您可以使用

bundle exec rake deploy

Bundler将获取Gemfile中列出的正确gem版本,然后执行命令。