How to find unused gems and cleanup gemfile

bundle clean --force will remove old gems (or older versions of currently-used gems) previously installed, but not currently being used in your current Gemfile.lock manifest.


First, if you want to check what are the gems used by your project, I invite you to run gem server in your project folder root, then go to http://0.0.0.0:8808/

You will be able to understand the dependencies of all the gems your project is using. It will also show you all versions of the same gem.

To remove old versions of gems you can run as @changingrainbows mention bundle clean --force

After this step run your gem server again and watch the result, a clean and understandable gem list with all dependencies.


It depends what you're after here.

If you're looking to remove old, unused gem versions, then bundle clean.

If you've been adding gems as you develop and have lost track of the ones you actually use, and have good test coverage, then try this answer.

If you want to reduce the number of gems rails pulls in at startup to the bare minimum, try gem_bench.