You have already activated X, but your Gemfile requires Y

前端 未结 8 2559
逝去的感伤
逝去的感伤 2020-11-27 10:43

When running rake I get this error:

You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Consider using bundle ex

8条回答
  •  清歌不尽
    2020-11-27 11:20

    If you have a reason to keep the current version of rake (or whatever other gem is causing the problem), matt is correct, the best way to do this is to run bundle exec. This uses the version specified in your Gemfile instead of using the newest version of the gem you have installed. (nathan.f77 has a good solution below if you don't want to type bundle exec every time you run rake)

    Otherwise, if there is no reason not to update rake, you can run

    bundle update rake
    

    This will actually update your Gemfile.lock to use the newest version of rake instead of having to run bundle exec every time.

    Note: if you run just bundle update this will update all the gems in your Gemfile instead of just rake, which probably isn't what you want, because if something breaks in your application you won't know which gem update caused it.


    The less recommended way to keep the older version without having to use bundle exec is to uninstall the newer versions of rake.

    $ gem uninstall rake
    
    Select gem to uninstall:
     1. rake-0.8.7
     2. rake-0.9.2
     3. All versions
    > 2
    Successfully uninstalled rake-0.9.2
    

    This works, but if you are working with multiple apps that use different versions of rake, this can be a pain because you will find yourself constantly having to install and uninstall different versions.

提交回复
热议问题