Removing all installed Gems and starting over

115,094

Solution 1

From the RVM support site:

RVM installs everything into ~/.rvm. To remove RVM from your system run 'rm -rf ~/.rvm'. You may have one additional config file in ~/.rvmrc and of course the RVM hook in your bash/zsh startup files.

So, just go to the command line and type rm -rf ~/.rvm

All the installed gems are in the ~/.rvm folders, so doing the above will remove the gems and installed rubies in one go.

Gems you added pre-RVM with the default ruby install can be removed by typing this at the command prompt:

for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done

Solution 2

gem uninstall -aIx

Uninstalls all gems without prompt.

Options

-a, --[no-]all                   Uninstall all matching versions
-I, --[no-]ignore-dependencies   Ignore dependency requirements while
                                 uninstalling
-x, --[no-]executables           Uninstall applicable executables without
                                 confirmation

Solution 3

For Windows and Unix copy/paste in command prompt (Ruby 1.9.x).

ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.strip.empty? }"

Solution 4

using RVM, you could just type...

rvm gemset empty GEMSET

where GEMSET is the gemset which you would like to empty. then...

install bundle

yum install bundler and finally

bundle install

Solution 5

rvm implode (see cli docs) seems to work - and it even tells you where to look at for leftovers

Share:
115,094
Dave Long
Author by

Dave Long

Application Developer with Recruitics managing the Analytics platform, I've worked across frontend, backend and database platforms constructing and optimizing a platform that currently accepts 1,000,000 requests per week.

Updated on May 05, 2021

Comments

  • Dave Long
    Dave Long almost 3 years

    I recently started learning Ruby and Ruby on Rails, and have watched a plethora of getting started materials. I have been finding lately that I keep getting errors where gems won't install or they will be installed but they can't be used for some reason, and I have decided that I want to remove everything down to once again just having Ruby installed and start over with the installation. One training video had me install most of my gems with RVM, so I don't know if that changes anything.

    So in short my question is "How to I get rid of RVM, Rubygems, and all installed Gems so that I can start over with just Ruby?"

    Edit: I am on Mac OS 10.6

  • Dave Long
    Dave Long about 13 years
    I just ran that, but gems is still installed. It does however look like it reloaded it. Not sure if it reloaded with defaults from Mac XCode or what...
  • michaelmichael
    michaelmichael about 13 years
    added another line to get rid of the gems you added pre-RVM
  • timmfin
    timmfin about 12 years
    I'd add the '-all -x -I' options to gem uninstall to prevent it from prompting you (for binaries, versions, or dependencies) while uninstalling.
  • Daniel Rehner
    Daniel Rehner over 11 years
    For reference, the full command is: for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
  • trisweb
    trisweb over 11 years
    For more reference, another option: gem list --no-versions | xargs gem uninstall -aIx
  • isomorphismes
    isomorphismes about 11 years
    ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME) -e:1: no .<digit> floating literal anymore; put 0 before dot bundle (0.0.1) ^ -e:1: syntax error, unexpected tINTEGER bundle (0.0.1) ^
  • Haris Krajina
    Haris Krajina about 11 years
    @isomorphismes not sure if I have fixed it, but you can try command now.
  • konung
    konung almost 11 years
    This actually works quite nicely with rbenv as well on Debian
  • mpowered
    mpowered over 6 years
    This is technically the most correct answer and exactly what it was designed for.
  • raingod
    raingod about 6 years
    doing this gave me the following error once i ran it and ran bundle install: ``` ~/.rvm/gems/ruby-2.5.0@global/bin/bundle: No such file or directory```
  • Nein
    Nein almost 4 years
    "implode - removes all ruby installations it manages, everything in ~/.rvm"
  • user2023370
    user2023370 over 3 years
    That gives me: ERROR: While executing gem ... (Gem::InstallError) gist is not installed in GEM_HOME, try: gem uninstall -i /usr/share/rubygems-integration/all gist
  • Mark Gavagan
    Mark Gavagan over 3 years
    "implode does not uninstall the RVM itself. Basically, there is no way to automatically uninstall RVM other than manually cleaning up everything that the installation did to your system. And that’s a huge downside. The only way to uninstall RVM is to manually clean up everything it did to your system." source: duseev.com/articles/rbenv-vs-rvm NOTE: I'm a novice and unqualified to determine whether the advice in the article is accurate.
  • chesterbr
    chesterbr over 3 years
    @MarkGavagan I agree it does not do everything, but it will tell you what else needs to be done (what I refer to above as "leftovers"). In fact, that very article's step zero on uninstalling rvm is... rvm impode :-)
  • Zuzu Softman
    Zuzu Softman over 3 years
    then you should do as it suggest. then after that, rerun gem uninstall -aIx again. repeat if error occured for other gem untill it finisehd
  • Beyar
    Beyar about 3 years
    Does this have the same effect as rvm gemset empty GEMSET?
  • chesterbr
    chesterbr over 2 years
    @Beyar I'm not super familiar with rvm gemset, but I think it won't remove the rvm tooling (including the rvm utility itself), nor the extra files that rvm implode will inform you about.
  • jox
    jox over 2 years
    You might want to grep for 'default:' instead (including the colon) since there are quite a few gems that include "default" in their name.