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

Jun*_*ooq 8 ruby rubygems ruby-on-rails 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)
Run Code Online (Sandbox Code Playgroud)

而当我这样做时,gem list rake它给了我

*** LOCAL GEMS ***

airbrake (4.3.1)
rake (10.5.0, 10.4.2)
Run Code Online (Sandbox Code Playgroud)

我想只有一个版本,当我做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
Run Code Online (Sandbox Code Playgroud)

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

小智 26

首先运行bundle update rake.

我希望这适合你.

  • 这才刚刚解决了我的问题.运行此更新后,不需要bundle exec. (4认同)

Sim*_*tti 11

您需要为命令添加前缀bundle exec.例如,如果您的rake命令是

rake deploy
Run Code Online (Sandbox Code Playgroud)

你改为使用

bundle exec rake deploy
Run Code Online (Sandbox Code Playgroud)

Bundler将获取您所列出的正确的gem版本Gemfile,并执行该命令.

  • 这不是一个解决方案。 (2认同)