Skip to content

Instantly share code, notes, and snippets.

@marianposaceanu
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marianposaceanu/11317173 to your computer and use it in GitHub Desktop.
Save marianposaceanu/11317173 to your computer and use it in GitHub Desktop.
# ___ ___ ___ ___ ___ ___ ___ ___
# /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ /\__\ |\__\
# /::\ \ /::\ \ /::| | /::\ \ /::\ \ /::\ \ /:/ / |:| |
# /:/\:\ \ /:/\:\ \ /:|:| | /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/ / |:| |
# /:/ \:\ \ /::\~\:\ \ /:/|:|__|__ /::\~\:\ \ /::\~\:\ \ /:/ \:\__\ /:/ / ___ |:|__|__
# /:/__/_\:\__/:/\:\ \:\__/:/ |::::\__\ /:/\:\ \:\__/:/\:\ \:\__/:/__/ \:|__/:/__/ /\______/::::\__\
# \:\ /\ \/__\:\~\:\ \/__\/__/~~/:/ / \/_|::\/:/ \:\~\:\ \/__\:\ \ /:/ \:\ \ /:/ \::::/~~/~
# \:\ \:\__\ \:\ \:\__\ /:/ / |:|::/ / \:\ \:\__\ \:\ /:/ / \:\ /:/ / ~~|:|~~|
# \:\/:/ / \:\ \/__/ /:/ / |:|\/__/ \:\ \/__/ \:\/:/ / \:\/:/ / |:| |
# \::/ / \:\__\ /:/ / |:| | \:\__\ \::/__/ \::/ / |:| |
# \/__/ \/__/ \/__/ \|__| \/__/ ~~ \/__/ \|__|
#
# Simple script to remove all installed gems
# without having to type gem uninstall 'gem_name'
# for each one of them
#
# Usage:
# gem list | ruby remove_all_gems.rb
#
# Notes:
# you might get some warning in the form of cannot
# remove default gem
ARGF.readlines[1..-1].each do |line|
gem = line.split(' ')
puts "Trying to remove #{gem[0]}"
output = `gem uninstall --executables --all --force #{gem[0].gsub(/\(|\)/, "")} 2>&1`
puts output unless (output.to_s =~ /because it is a default gem/)
end
puts "Gems removed / check status with gem list"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment