13

I am having some trouble removing the rake gem version 0.9. I managed to run gem uninstall rake and I believed this to have deleted it. However, going back to gem list it still showed that it still exists.

Running gem env:

GEM PATHS:
   /home/sean/.rvm/gems/ruby-1.9.2-p180
   /home/sean/.rvm/gems/ruby-1.9.2-p180@global

I went into the @global directory and manually deleted it there, yet still it remains somewhere. I can see it when I run gem list. The 0.9 rake gem is causing problems for my Rails 3.0.7 application.

I ran gem list -d rake:

rake (0.9.0, 0.8.7)

Installed at 
(0.9.0): /home/sean/.rvm/gems/ruby-1.9.2-p180@global
(0.8.7): /home/sean/.rvm/gems/ruby-1.9.2-p180

I don't see anything in the gems directory for ruby-1.9.2-p180@global

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
sean
  • 131
  • 1
  • 1
  • 4
  • Are you using an RVM gemset in your app? – Ben Moss May 23 '11 at 01:42
  • I think there is a file that contains the list of gems that are installed, and it doesn't get cleaned out correctly. Try doing a `grep -ci rake | grep -v :0$` and look at the files containing references to it. One is just a list. Remove `rake` from the list and you should be good. I can't remember the file to check for - it's been several weeks, but I had to do it on several machines. – the Tin Man May 23 '11 at 04:24

6 Answers6

48

You should run

rvm use @global && gem uninstall rake -v 0.9.0  
rvm use @ && gem uninstall rake -v 0.9.0

to correctly remove rake 0.9.0 from rvm

Alexey Chernikov
  • 1,785
  • 2
  • 11
  • 9
  • 1
    `rvm use @global && gem uninstall rake -v 0.9.0` worked like a charm for me. Thanks! – Joshua Cody May 31 '11 at 15:01
  • Worked perfectly for me, too! Thanks so much – boo-urns Jun 09 '11 at 19:11
  • `rvm use @ && gem uninstall rake -v 0.9.2` was the one for me... but that did the trick! Thanks! – brandonjp Sep 19 '11 at 17:24
  • 1
    @Alexey I get `rake (10.1.0, 0.9.6)` when running `ruby -S gem list` but cannot `gem uninstall rake -v 0.9.6` as it says `ERROR: While executing gem ... (Gem::InstallError) gem "rake" cannot be uninstalled because it is a default gem` Any hint? Thanks! :) – Steven Sep 24 '13 at 16:00
  • @Steven, I have the same versions installed and get the same error. (gem list -d shows: Installed at (10.1.0): .rvm/gems/ruby-2.0.0-p0@global (0.9.6, default): .rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0 ) – Tyler Rick Oct 08 '13 at 01:10
  • 3
    @Steven, Using the `--backtrace` I figured out where the error was coming from (`.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/uninstaller.rb:107`). That led me to look for a default dir, which I found at `.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/specifications/default`. I ended up just manually deleting the files with `rm -r .rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/rake-0.9.6/ .rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/specifications/default/rake-0.9.6.gemspec` http://stackoverflow.com/questions/15100496/uninstalling-all-gems-ruby-2-0-0 also had some ideas. – Tyler Rick Oct 08 '13 at 01:26
  • @TylerRick I am currently not trouble shooting on this any more as there are more urgent things at the moment. Will be back as soon as time's come to deal with this problem again. Thanks already for the approach! – Steven Oct 08 '13 at 08:42
  • @Steven, no problem, I was just posting my solution in the hopes that it might help someone somewhere... – Tyler Rick Oct 09 '13 at 15:17
3

In terminal type in: gem uninstall rake, then select version 0.9.0 when prompted.

Then modify your Gemfile within your Rails application:

gem 'rake', '0.8.7'

Then in terminal run:

bundle install

These steps should fix the problems you are having. Upgrade to rake again when you upgrade to rails 3.1.

JZ.
  • 21,147
  • 32
  • 115
  • 192
2

If you're using rvm you get rake 0.9 installed "for free" in the global gemset which makes it hard (impossible?) to uninstall properly. gem uninstall rake is successful but doesn't actually remove rake 0.9. I had to do it manually for both REE and 1.9.2.

I edited the rake executable script (find with which rake) and added a:

puts "Gem.bin_path: #{Gem.bin_path('rake', 'rake', version)}

...before the last line. This prints (on my system): Gem.bin_path: ~/.rvm/gems/ree-1.8.7-2011.03@global/gems/rake-0.9.0/bin/rake

To remove 0.9 cd into ~/.rvm/gems/ree-1.8.7-2011.03 and manually delete all rake-0.9 files (gems, specifications are the ones that count I believe).

dvdplm
  • 691
  • 7
  • 8
2

I ran into this same problem (needed rake 0.8.7 but got 0.9.0 "for free" with rvm). Initially gem list -d rake gave the following output:

rake (0.9.0, 0.8.7)
  Installed at (0.9.0): ~/.rvm/gems/ruby-1.9.2-p136@global
               (0.8.7): ~/.rvm/gems/ruby-1.9.2-p136@my_gemset

Switching to the global gemset with rvm use @global gave me this output:

rake (0.9.0)
  Installed at: ~/.rvm/gems/ruby-1.9.2-p136@global

So I just did gem uninstall rake. Now, switching back to my gemset with rvm use @my_gemset the correct version of rake (0.8.7) is being used.

metavida
  • 1,341
  • 11
  • 12
2

If you're using bundler, you should read this excellent article by Yehuda Katz. Following his instructions means you don't have to uninstall rake 0.9.0. Try following command:

bundle exec rake --version

Prepending bundle exec will make sure that only the correct version of the rake is loaded, regardless of others you have installed.

Andrew
  • 227,796
  • 193
  • 515
  • 708
metavida
  • 1,341
  • 11
  • 12
0

Did you try using the 'gem cleanup' script ?

Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
  • I tried 'gem cleanup' and it still appears in 'gem list'. But I don't see it in the gem path directories. – sean May 23 '11 at 01:17
  • Only one version of ruby installed? – Antarr Byrd May 23 '11 at 01:22
  • I inserted this into my rakefile above the load_tasks line: Whatever::Application.send :include, ::Rake::DSL if defined?(::Rake::DSL) So it looks like the rails app works now using rake 0.9. – sean May 23 '11 at 02:02