Rails: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2 (Gem::LoadError)

后端 未结 15 1772
自闭症患者
自闭症患者 2020-12-05 02:21

Here is my error:

rake aborted!
Gem::LoadError: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to yo         


        
相关标签:
15条回答
  • 2020-12-05 02:39

    My error message:

    ~ $ rake db:migrate                                                                                                                                                                            [2.6.5][10:21:00]
    rake aborted!
    Gem::LoadError: You have already activated rake 12.3.2, but your Gemfile requires rake 13.0.1. Prepending `bundle exec` to your command may solve this.
    /Users/torvalds/workspace/ekohe/whitespace/config/boot.rb:5:in `<top (required)>'
    /Users/torvalds/workspace/ekohe/whitespace/config/application.rb:3:in `require_relative'
    /Users/torvalds/workspace/ekohe/whitespace/config/application.rb:3:in `<top (required)>'
    /Users/torvalds/workspace/ekohe/whitespace/Rakefile:6:in `require_relative'
    /Users/torvalds/workspace/ekohe/whitespace/Rakefile:6:in `<top (required)>'
    (See full trace by running task with --trace)
    

    I am using the rbenv to manage my Ruby environment.

    My global Ruby version is as know as the default Ruby version is 2.7.1, because I set it as rbenv global 2.7.1. However, my rake under Ruby 2.7.1 is 12.3.2

    ~ $ rake --version
    
    rake, version 12.3.2
    

    My project Ruby version is 2.6.5. however, my rake under Ruby 2.6.5 in my project is 13.0.1

    ~ $ bundle exec rake --version
    
    rake, version 13.0.1
    

    so I have to uninstall global rake

    ~ $ gem uninstall rake
    

    and reinstall it back

    ~ $ gem install rake
    
    Fetching rake-13.0.1.gem
    Successfully installed rake-13.0.1
    1 gem installed
    

    it works! ~~~

    I'm not sure whether it will have an influence on other projects. However, so far it works.

    0 讨论(0)
  • 2020-12-05 02:40

    As mentioned on earlier answers this is a simple issue which happens when your gemset has a rake version that is newer than the version number your Gemfile.lock mentions.

    The easiest way to debug this is to run bundle update.

    The other ways could be to remove Gemfile.lock and running bundle install or simply deleting the line in Gemfile.lock that corresponds to the rake version and try bundle install. But this might sometimes corrupt the Gemfile. I would prefer the first method because it is the safest and the easiest.

    0 讨论(0)
  • 2020-12-05 02:41

    I had the same error:

    You have already activated rake 12.0.0, but your Gemfile requires rake 11.3.0. Prepending "bundle exec" to your command may solve this.

    I solved it by running bundle update

    this updated the rake version to my activated rake version and everything worked I hope that works for you!

    0 讨论(0)
  • 2020-12-05 02:44

    I experienced this issue:

    Here's my solution:

    Solution 1:

    This solution works a lot of the time, simply update the gem causing the issue, say the gem is rack

    bundle update rack
    

    Solution 2:

    In some cases Solution 1 may not work, and you will need to edit your Gemfile.lock file.

    Simply, open your Gemfile.lock file and then change the version to the update requested.

    In my case, the gem was rack, I had rack 2.0.7 defined in my Gemfile.lock file, but my application required rack 2.1.2, I simply had to modify it to rack 2.1.2 in the Gemfile.lock file.

    I then had to uninstall the previous version of rack which is rack 2.0.7

     gem uninstall rack -v 2.0.7
    

    And finally installed the new gem in production

    bundle install --without development test
    

    Solution 3:

    In very rare cases Solution 1 and Solution 2 may not work, and you will need to edit your Gemfile before updating the gem.

    In my case, the gem was puma, I had puma ~> 3.11 defined in my Gemfile, but my application required puma ~> 4.3.1. At this point running bundle update puma and editing my Gemfile.lock file didn't work, since puma ~> 3.11 version specified in the Gemfile would not allow an update to puma ~> 4.3.1.

    I simply had to change the version of puma in the Gemfile to puma ~> 4.3.1 and then ran the command.

    bundle update puma
    

    That's all.

    I hope this helps

    0 讨论(0)
  • 2020-12-05 02:45

    Go in the Gemfile.lock, find the rake file and update the version there.

    I got this error:

    Gem::LoadError: You have already activated rake 11.2.2, but your Gemfile requires rake 11.1.2. Prepending bundle exec to your command may solve this.

    What I did was to change the version of rake in the Gemfile.lock from: rake (11.1.2) to rake (11.2.2).

    Everything worked fine after that.

    0 讨论(0)
  • 2020-12-05 02:47

    You can use rubygems-bundler to solve this. Run the following commands:

    $ gem install rubygems-bundler

    $ gem regenerate_binstubs

    Then try your rake again.

    0 讨论(0)
提交回复
热议问题