How do I activate a different version of a particular gem?
If your problem is to run binaries of a certain version, then:
rails --version # => the latest version
rails _2.3.10_ --version # => Rails 2.3.10
This pattern (gem-binary _gem-version_
) works for any gem binary.
Hope it helps.
How to switch between different version of gem installed?
You can specify a version in gemfile of your project
gem "rack", "1.3.5"
Pointed by matt
:
To use gem specified in Gemfile:
bundle exec cucumber
How to run a specific version of a ruby gem
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.
how to get bundler to use an older bundler gem version?
You can use bundle _version_ install
to install gems using a specific version.
Here's an example:
bundle _1.0.21_ install
or
bundle _1.0.21_ -v
# Bundler version 1.0.2
Reference: http://makandracards.com/makandra/9741-run-specific-version-of-bundler
How to `bundle install` when your Gemfile requires an older version of bundler?
First you need to install the appropriate version of bundler:
% gem install bundler -v '~> 1.0.0'
Successfully installed bundler-1.0.22
Then force rubygems to use the version you want (see this post):
% bundle _1.0.22_ install
Bundler - cannot load 2 different versions of the exact same gem?
You cannot have two different versions of the same gem loaded the same program, because they could conflict and override each other's methods. For example, suppose you have a gem which contains the following:
# In gem version 1.0
class AneMaria
def self.name
"Ane"
end
end
######
# In gem version 2.0
class AneMaria
def self.name
"Maria"
end
end
And then in your code, if you call AneMaria.name
, what should it return??
One of the reasons tools like bundler
were created was to prevent this from happening accidentally -- so no, you cannot specify 2 different versions of a gem to load simultaneously. (Also, I don't think you'll ever want to do that!)
See also this post, which explains things a little more.
Related Topics
Why Should We Avoid Using Class Variables @@ in Rails
Xpath Axis, Get All Following Nodes Until
Total Newbie: Instance Variables in Ruby
Rails: Skinny Controller Vs. Fat Model, or Should I Make My Controller Anorexic
Stop Devise from Clearing Session
Why Do Two Strings Separated by Space Concatenate in Ruby
Getting a "Bad Interpreter" Error When Using Brew
Iterate Over Ruby Time Object With Delta
Ruby: Problem Installing Eventmachine Under Windows 7
Ruby Gsub Doesn't Escape Single-Quotes
Can Ruby Print Out Time Difference (Duration) Readily
How to Install MySQL2 Gem on Windows 7
Set Utf-8 as Default String Encoding in Heroku
Idiomatic Object Creation in Ruby