How to uninstall all gems installed using `bundle install`

nish picture nish · Jan 27, 2014 · Viewed 57.6k times · Source

How can I remove all the gems installed using bundle install in a particular RoR project. I don't want to uninstall gems that are used by other projects.

Answer

rainkinz picture rainkinz · Jan 27, 2014

Since we're using ruby you could do something like this I guess:

bundle list | ruby -e 'ARGF.readlines[1..-1].each {|l| g = l.split(" ");  puts "Removing #{g[1]}"; `gem uninstall --force #{g[1]} -v #{g[2].gsub(/\(|\)/, "")}`; }'

NOTE: Only lightly tested.