在你的命令前加上 `bundle exec` 可能会解决这个问题 rails

Prepending `bundle exec` to your command may solve this rails

我在将网站部署到 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

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

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

rake deploy

您必须改为使用

bundle exec rake deploy

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

首先 运行 捆绑包更新抽成 .

希望这对你有用。