Last Updated: December 07, 2021
·
4.791K
· Marko Klemetti

Clean your Bundles

Are you using RVM and Bundler?

You might be aware that once change your Gemfile and re-run bundle or bundle install, the old gems in the gemset will not be deleted.

Usually this does not matter as your execution is using the latest versions of your gems. However if you end up downgrading your gems your project might accidentally use wrong dependencies.

Then you should clean your gemset using bundler:

$ bundle clean --force

Example

You have tried to upgrade to Rails 3.2.11, but your has_many <dependency> does not yet inclue inverse_of:. Now your specs fail.

As you revert back to e.g. Rails 3.2.8, your activesupport 3.2.11 will not be updated, and your specs will still fail (unless you strictly use bundle exec <command>). After running bundle clean --force, if your gemset has been correctly set, you don't need bundle exec and all will work as expected.