24

My system is F'd. How do I completely uninstall rails, ruby and rubygems?

any suggestions on where to go to reinstall from scratch? Best practices? I'd like to get back to 3.0 beta

Thanks!

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

3 Answers3

26

You can use gem uninstall to delete all gems as follows:

gem list --no-version | xargs gem uninstall

If you want to keep eg. the gem rake:

gem list --no-version | grep -v "rake" | xargs gem uninstall

To delete only the old versions, you can run gem clean.


Also, it is possible to write all gems in a list:

gem list --no-version > gem_list.txt 

and define these you want to delete:

cat gem_list.txt | xargs gem uninstall 

or install:

cat gem_list.txt | xargs gem install

(eventually you have to put a sudo in front of a gem command. On windows use an unix console enviroment like msysGit)

raptor
  • 319
  • 3
  • 5
  • 5
    Thanks! This was hot. I modified it a bit to automatically remove all bin executables and every version of a gem: 'gem list --no-version | sudo xargs gem uninstall $1 -a -x' – Chuck Bergeron Feb 11 '12 at 17:53
9

I suggest you to simply uninstall all Gems using gem uninstall [name_of_gem], then use RVM to install a new Ruby version and make it the default one.

RVM also makes incredibly easy to remove a Ruby version and all its data since it installs everything in a folder within your home directory.

Joseph Ravenwolfe
  • 6,480
  • 6
  • 31
  • 31
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
2

Use

$gem clean

for delete all the gems.

Ravi Kant
  • 69
  • 7