It’s generally a good idea to keep your gem installation clean and you can do that by doing
gem cleanup or
gem cleanup [GEM_NAME] which will remove the older versions of the gem. Of course, some times, you have applications (or other gems) that rely on a specific version – so, you need to keep those (or re-install them using bundle install).
However, bundler itself is a bit special. You can try to do
gem list bundler and you will likely see something like this:
❯ gem list bun *** LOCAL GEMS *** bundler (2.2.4, 2.1.4, default: 1.17.2)
So, you have more than one gem but also the default is 1.17.2 – not something newer. Of course, the first step is try to do a
gem clean bundler and you will see that it only removes 2.1.4 and does not change the ‘default’ since that’s the default that came with the Ruby installation.
❯ gem list bundler *** LOCAL GEMS *** bundler (2.2.4, default: 1.17.2)
To update this, what you need to do is actually update the gem subsystem which will also update bundler.
❯ gem update --system Updating rubygems-update Fetching rubygems-update-3.2.6.gem Successfully installed rubygems-update-3.2.6 Parsing documentation for rubygems-update-3.2.6 Installing ri documentation for rubygems-update-3.2.6 Installing darkfish documentation for rubygems-update-3.2.6 Done installing documentation for rubygems-update after 152 seconds Parsing documentation for rubygems-update-3.2.6 Done installing documentation for rubygems-update after 0 seconds Installing RubyGems 3.2.6 Successfully built RubyGem Name: bundler Version: 2.2.6 File: bundler-2.2.6.gem Bundler 2.2.6 installed RubyGems 3.2.6 installed Regenerating binstubs Regenerating plugins Parsing documentation for rubygems-3.2.6 Installing ri documentation for rubygems-3.2.6 # 3.2.6 / 2021-01-18 ## Enhancements: * Fix `Gem::Platform#inspect` showing duplicate information. Pull request #4276 by deivid-rodriguez ...(long list of changes) RubyGems system software updated
Most importantly, it shows the RubyGems system software was updated. Great! Let’s do our check again of the Bundler versions.
Ah, it added 2.2.6 as the default which is newer than the version we had previously and removed the 1.17.2 that was the previous default. If you want now, you can remove the 2.2.4 by simply doing
gem cleanup bundler and it will be gone, leaving you with a clean single bundler that is also the default.
> gem cleanup bundler Cleaning up installed gems... Attempting to uninstall bundler-2.2.4 Successfully uninstalled bundler-2.2.4 Clean up complete > gem list bundler *** LOCAL GEMS *** bundler (default: 2.2.6)
I wrote this up because I had to search a few things to put the pieces together, and I wan to be able to remember how to do it the next time. Of course, if it helps someone, that’s great! If you have some comments, please add below so that I can reflect changes here.