21

I updated a gem while I had the Rails server running and now I have two 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.2 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.

How can I update it properly so that the server will use 2.0.2 instead of 2.0.1, or how do I remove the 2.0.1 version of the gem?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user1116573
  • 2,817
  • 4
  • 17
  • 27
  • 1
    you can explicitly tell your program to make use of the `2.0.2` version by declaring something like this ``, `'2.0.2'` in you Gemfile. – uday Apr 17 '12 at 22:16
  • 1
    possible duplicate of [Uninstall old ruby gem's versions](http://stackoverflow.com/questions/5902488/uninstall-old-ruby-gems-versions) – 410 gone Jan 08 '14 at 11:30

2 Answers2

33

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

gem uninstall gem_name --version version

To remove bootstrap-sass 2.0.1 use:

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 to use ONLY version 2.0.2:

gem 'bootstrap-sass', '2.0.2'

Or

gem 'bootstrap-sass', '~> 2.0.2'

will use the greatest version higher than 2.0.2 but less than 2.1.

See "Specifying Versions in a Gemfile" for more information.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Paul Simpson
  • 2,504
  • 16
  • 28
  • Thanks Paul. I chose to uninstall version 2.0.1 using your script and it now uses 2.0.2 as required. I've never updated a gem before, do you think this was caused by having the webserver running when I did it? – user1116573 Apr 18 '12 at 18:04
1

This will remove version 2.0.1 and 2.0.2:

gem uninstall bootstrap-sass --version 2.0.1
gem uninstall bootstrap-sass --version 2.0.2

This will remove all old versions of the gem:

gem cleanup bootstrap-sass

This lets you choose which ones you want to remove:

gem uninstall bootstrap-sass
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Suriyaa
  • 2,222
  • 2
  • 25
  • 44