Howto remove / fix “Gem::LoadError: can’t activate rake- v1 , already activated rake- v2″ on Ruby on Rails

undefined

In this mini post I’ll show you how to switch to the correct rake version your rails app needed instead of the one already activated. I faced the following errors when I was deploying my app.

Here’s the error I faced “SSHKit::Command::Failed: RAILS_ENV=production bundle exec rake assets:precompile exit status ” At the end of this error message I found the reason of this error which was “Gem::LoadError: can’t activate rake-11.3.0, already activated rake-10.4.2” also I found “Gem::LoadError: You have already activated rake 11.3.0, but your Gemfile requires rake 10.4.2. Using bundle exec may solve this."

So, all what I need to do is to activate rake version 10.4.2. This because I have more than one rake version installed on my system.

Solutions:

  • Method 1: Remove all existing rake versions

In this method, we will remove all installed rake  versions and install the needed rake version, run the following commands:

 $ gem uninstall rake

Select gem to uninstall:
 1. rake-10.4.2
 2. rake-11.1.2
 3. rake-10.1.1
 4. rake-11.2.2
 5. rake-10.3.2
 6. rake-11.3.0
 7. All versions
> 7
Successfully uninstalled rake-10.4.2
Successfully uninstalled rake-11.1.2
Successfully uninstalled rake-10.1.1
Successfully uninstalled rake-11.2.2
Successfully uninstalled rake-10.3.2
Successfully uninstalled rake-11.3.0

As you see, “gem uninstall rake” listed all installed versions of rake on my system, and I selected the last option “All Versions“. Now All versions of rake are removed.

Next, we need to install the rake version needed by my app, run the following command:

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies........
Installing rake 10.4.2
......

This command will install all the needed gems and of course will install the correct version of rake.

Now you can safely deploy your app using the following command:

$ bundle exec cap --trace production deploy

And my app deployed successfully.

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *