Remove/Uninstall old version of ruby gem

Remove/Uninstall old version of ruby gem

I updated a gem whilst I had the rails server running and now I have 2 versions of the gem installed in my gemset.
I updated using bundle update bootstrap-sass and now have both 2.0.1 and 2.0.2.
The server seems to be serving up the 2.0.1 version so I assume it should have removed the 2.0.1 version when it did the update and didn’t because the gem was in use at the time.
Can someone tell me how to either update it properly so that the server will use 2.0.2 instead of 2.0.1 or how to remove the 2.0.1 version of the gem.


Solution 1:

You can remove a specific version of a gem by using this command:

gem uninstall gem_name --version version

To remove bootstrap-sass 2.0.1 that would be:

gem uninstall bootstrap-sass --version 2.0.1

Alternately, you could tell bundler to use a particular version, as others have suggested. In your Gemfile:

Related:  Bootstrap Modal Dialog. Can the grid system be used within a modal context?

gem 'bootstrap-sass', '2.0.2' will use ONLY version 2.0.2

gem 'bootstrap-sass', '~> 2.0.2' will use the greatest version higher than 2.0.2 but less than 2.1.

More Information on Specifying Versions in a Gemfile

Solution 2:

The method you need:

# remove version 2.0.1 and 2.0.2 only
gem uninstall bootstrap-sass --version 2.0.1
gem uninstall bootstrap-sass --version 2.0.2

Other methods to remove gems from your PC:

# remove all old versions of the gem
gem cleanup bootstrap-sass

# choose which ones you want to remove
gem uninstall bootstrap-sass