Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# ___ ___ ___ ___ ___ ___ ___ ___
# /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ /\__\ |\__\
# /::\ \ /::\ \ /::| | /::\ \ /::\ \ /::\ \ /:/ / |:| |
# /:/\:\ \ /:/\:\ \ /:|:| | /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/ / |:| |
# /:/ \:\ \ /::\~\:\ \ /:/|:|__|__ /::\~\:\ \ /::\~\:\ \ /:/ \:\__\ /:/ / ___ |:|__|__
# /:/__/_\:\__/:/\:\ \:\__/:/ |::::\__\ /:/\:\ \:\__/:/\:\ \:\__/:/__/ \:|__/:/__/ /\______/::::\__\
# \:\ /\ \/__\:\~\:\ \/__\/__/~~/:/ / \/_|::\/:/ \:\~\:\ \/__\:\ \ /:/ \:\ \ /:/ \::::/~~/~
# \:\ \:\__\ \:\ \:\__\ /:/ / |:|::/ / \:\ \:\__\ \:\ /:/ / \:\ /:/ / ~~|:|~~|
# \:\/:/ / \:\ \/__/ /:/ / |:|\/__/ \:\ \/__/ \:\/:/ / \:\/:/ / |:| |
# \::/ / \:\__\ /:/ / |:| | \:\__\ \::/__/ \::/ / |:| |
# \/__/ \/__/ \/__/ \|__| \/__/ ~~ \/__/ \|__|
#
# 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
You can’t perform that action at this time.