Uninstall All Installed Gems, in Osx

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



Leave a reply



Submit