Uninstall all installed gems, in OSX?
You could also build out a new Gemfile and run bundle clean --force
. This will remove all other gems that aren't included in the new Gemfile.
Removing all installed Gems and starting over
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
Remove all installed Gems except for specific versions
It's actually 8 effective lines of code :) (not including gathering inputs)
# output of `gem list` command
all_gems = <<-GEMS
rvm-capistrano (1.2.7, 1.2.6)
sinatra (1.4.2, 1.3.5, 1.3.3)
tilt (1.4.1, 1.3.7, 1.3.6, 1.3.5, 1.3.3)
GEMS
we_need_these = {
'sinatra' => '1.4.2',
'tilt' => '1.4.1'
}
all_gems.split("\n").each do |line|
versions = line.gsub(/[\(\),]/, '').split(' ')
gem_name = versions.shift
versions.each do |v|
unless we_need_these[gem_name] == v
# `puts` is used for demonstration purposes.
# you'll want to use backticks or `system` method or similar
puts "gem uninstall #{gem_name} -v #{v}"
end
end
end
# >> gem uninstall rvm-capistrano -v 1.2.7
# >> gem uninstall rvm-capistrano -v 1.2.6
# >> gem uninstall sinatra -v 1.3.5
# >> gem uninstall sinatra -v 1.3.3
# >> gem uninstall tilt -v 1.3.7
# >> gem uninstall tilt -v 1.3.6
# >> gem uninstall tilt -v 1.3.5
# >> gem uninstall tilt -v 1.3.3
Related Topics
Error: Mime-Types-Data Requires Ruby Version >= 2.0
Netbeans and Rails Error: Bin/Ruby: No Such File or Directory -- Script/Rails (Loaderror)
Rails: Specified 'Mysql2' for Database Adapter But the Gem Is Not Loaded
Split the String to Get Only the First 5 Characters
Ruby: Installing Rmagick on Ubuntu
Ruby on Rails - Unable to Convert "\X89" from Ascii-8Bit to Utf-8 for Xxx/Xxxx/Xxxx
Installed Ruby Using Apt-Get Install Ruby 2.0.0 Succeeded But Not Using Correct Ruby Version
Rubyinstaller 2.2.1 and Rails - Rake Cannot Load Nokogiri
Passing Multiple Code Blocks as Arguments in Ruby
Flutter Pod Install Problem - Undefined Method 'Each_Child' For #≪Dir:0X00007Fa6F7E2Ec80≫
A Method with an Optional Parameter
Is There a "Phpmyadmin" for Ruby on Rails
How Does Load Differ from Require in Ruby
Why Is Sudo: Bundle Command Not Found
Need to Split Arrays to Sub Arrays of Specified Size in Ruby