Uninstall old versions of Ruby gems

Philippe Blayo picture Philippe Blayo · May 5, 2011 · Viewed 294.7k times · Source

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?

Answer

Dylan Markow picture Dylan Markow · May 5, 2011
# 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'