138

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.

5 Answers 5

256
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

5
  • 11
    [DEPRECATED] The --force option has been renamed to --redownload
    – Rimian
    Feb 10, 2020 at 23:47
  • 2
    @Rimian I don't think --force option is deprecated. Bundler docs say that --redownload is an alias for that option, but nothing about deprecating --force.
    – Rouger
    Feb 11, 2020 at 13:26
  • 4
    I copied that straight from std out. I guess we will find out at some point!
    – Rimian
    Feb 11, 2020 at 22:47
  • 2
    --force option still works but it raises a deprecation warning if you use it (bundler 2.1.4). I guess it will be totally deprecated in the next major upgrade Sep 10, 2020 at 8:18
  • 1
    Note: If you're doing this locally to test that a live deployment will succeed, then add the --deployment switch to force the usage of the exact versions specified in your Gemfile (and ignore patch upgrades like ~> 0.3.2 which would normally upgrade to e.g. 0.3.6). See stackoverflow.com/a/66791138/1852005
    – stwr667
    Aug 31, 2022 at 12:19
8

Brutish but clever:

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

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

2

If you completely want to reinstall everything from scratch you can just, locate your gem dir, for example if you use rvm it would be ~/.rvm/gems then locate your ruby version alongside with gemset for example ruby-2.7.0@some_particular_gemset (it will be a dir) and then just delete it.

rm -rf ruby-2.7.0@some_particular_gemset

bundle install
1

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.