How to uninstall all gems installed using `bundle install`

Solution 1:

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.

Solution 2:

There's no one simple way to remove all gems - let alone removing those within a specific bundle. You could try some of these suggestions: Uninstall all installed gems, in OSX?

Adapt to the bundle show command instead of gem list


For the future, try this approach:

If you install your bundle locally like the example below, the gems won't be installed in your global gem directory. Then you can easily delete the installation folder to delete all gems of the bundle.

# install gems to project_root/vendor/bundle
bundle install --path vendor/bundle --without test

The path option is saved to .bundle/config just like all others and any subsequent bundle install calls will use it unless you set it to something else or remove it from the config!

Solution 3:

You can use (like Tobias says, if you are using RVM)

rvm gemset empty [gemset]

Directly on the gemset, for example

rvm gemset empty 2.0.0@server

Solution 4:

It is actually as simple as

gem list --no-versions | xargs gem uninstall -a

If you are not using RVM/RBENV, you might hit into issue when gem attempts to uninstall system library which can fail. In that case, call uninstall command one by one to skip these.

gem list --no-versions | xargs -n1 gem uninstall -a