Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstall old versions of Ruby gems

Tags:

ruby

gem

I have several versions of a Ruby gem:

$ gem list rjb (1.3.4, 1.3.3, 1.1.9) 

How can I remove old versions but keep the most recent?

like image 448
Philippe Blayo Avatar asked May 05 '11 18:05

Philippe Blayo


People also ask

How do I uninstall old Ruby version?

Any gems that you install while using an RVM's ruby version, is self contained in that version. However there may come a time when you no longer want to use a particular ruby version and want to delete it along with all it's gems. Then this can be done using the “remove” command.

How do you clean ruby gems?

To remove older gems we use the clean command: The cleanup command removes old versions of gems from GEM_HOME that are not required to meet a dependency. If a gem is installed elsewhere in GEM_PATH the cleanup command won't delete it. If no gems are named all gems in GEM_HOME are cleaned.

How do I uninstall and reinstall a gem?

If you've installed into ./bundle/vendor or similar, you need to remove the gem first but explicitly specify the GEM_HOME, e.g. This is by far the simplest way to uninstall gems installed using bundler into a vendor directory. Ideally, there would be a command bundle uninstall or bundle reinstall , etc.


2 Answers

# remove all old versions of the gem gem cleanup rjb  # choose which ones you want to remove gem uninstall rjb  # remove version 1.1.9 only gem uninstall rjb --version 1.1.9  # remove all versions less than 1.3.4 gem uninstall rjb --version '<1.3.4' 
like image 137
Dylan Markow Avatar answered Sep 28 '22 02:09

Dylan Markow


For removing older versions of all installed gems, following 2 commands are useful:

 gem cleanup --dryrun 

Above command will preview what gems are going to be removed.

 gem cleanup 

Above command will actually remove them.

like image 32
ohho Avatar answered Sep 28 '22 00:09

ohho