Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a specific version of a ruby gem

I am running brakeman outside of my Gemfile, so am not using bundler.

If I do gem list, I can see I have the following for brakeman

brakeman (3.3.3, 3.3.2, 3.1.4, 3.1.2)

But if I do brakeman --version, I get

brakeman 3.1.2

so I am not using the latest version. If I do gem update brakeman or

gem update brakeman, '3.3.3,

I get

Updating installed gems
Nothing to update

So how do I run brakeman version 3.3.3?

like image 496
Obromios Avatar asked Aug 12 '16 06:08

Obromios


People also ask

How do I use a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


2 Answers

If you have several gem versions installed and you want to invoke a specific version from the command-line, you could use:

brakeman _3.3.3_ [args go here]

This is not specific to brakeman, you can do this for most other gems as well.

like image 139
awendt Avatar answered Sep 19 '22 11:09

awendt


I can't reproduce this issue, but I can think of a few reasons why this might happen:

  • Bundler artifacts (perhaps in .bundle/) pointing to the old version. Try running in a different directory and see if it still happens
  • A bug in RubyGems (try gem update --system)
  • During install, it asked if you wanted to replace the brakeman binary and you selected "no"
  • If you are using a Ruby version manager, maybe one version is on a different path than another (like a system gem versus one managed by rvm)
  • Any number of GEM_PATH, bundler, gem, rvm weirdness that sometimes occurs

In any case, if I were you I'd gem uninstall brakeman, remove all versions, and install fresh. If you are using rvm, start with a fresh gemset or rvm gemset empty the current one.

like image 40
Justin Avatar answered Sep 17 '22 11:09

Justin