Tag Archives: Gems

Uninstall all local ruby gems

This ruby script might be useful for people like me who just started using bundler to manage the gems of their webapp and all others, which want to clean up their gems. Caution: all installed gems are removed from rubygems!

1
2
3
4
5
6
7
f = open("|gem list")
output = f.read()
 
output.each_line do |l|
	gem_name = l.split(" ").first
	system "gem uninstall --a --ignore-dependencies #{gem_name}"
end

Basically this script just executes the “gem list” command, fetches the output, extracts the gem name and uninstalls it.