'How do I force Bundler to reinstall all of my gems?

How do I force Bundler to reinstall all of the gems in my gemfile? Or, how do I force Bundler to uninstall all of the gems it installed so I can then reinstall them myself?


I saw rails bundle clean, but this question explains how to remove gems that bundle installed but are no longer in the gemfile.

And How to reinstall a gem using bundler explains how to reinstall a single gem. I would like to reinstall all of my gems at once.



Solution 1:[1]

bundle install --redownload

See the reference for bundle install: https://bundler.io/v2.2/man/bundle-install.1.html

or

bundle install --force

For older versions of bundler

Solution 2:[2]

You can also delete the vendor directory and do bundle install again.

Solution 3:[3]

Brutish but clever:

  1. Comment out your entire Gemfile. (Don't delete it)
  2. bundle clean
  3. Restore your Gemfile.
  4. bundle install

Solution 4:[4]

Another way to deal with gem problems can be to sudo gem clean instead of reinstalling everything

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thilo
Solution 2 Marhadiasha Kusumawardhana
Solution 3 David Hempy
Solution 4 Jose Paez