Use different gem version on command line
Hello. I have installed rails 3.2.17, 4.0.4. When I call rails on command line it will use 4.0.4. I want to call 3.2.17 and find the answer in Stackoverflow:
$ rails _3.2.17_ new app
Is there any document on this feature? Thanks!
Hey JuanitoFatas, you may want to look into RVM and gemsets.
https://rvm.io/gemsets/basics
Using gemsets, you can manage multiple versions of rails without the need to use undocumented hacks.
Thanks for the heads up, @knappe. You're right!
I think it's documented somewhere, but it isn't a hack.
I will check.
I don't think I've seen documentation for it. But its logic is included in all installed gem executables
As @bf4 points out (thanks), it's here: https://github.com/rubygems/rubygems/blob/master/lib/rubygems/installer.rb#L644. Should I add docs? Where is appropriate? Thanks.
My point here is that RVM was designed for exactly this case. Ruby/gem managers (RVM, rbenv, ect) exist for to manage both ruby versions and gemsets.
This is common to every ruby project I've ever worked on whereas the underscore syntax is not. Why use a (to date) undocumented feature when tools exist to solve this problem and are widely used.
@knappe Yes, use RVM to manage different Ruby versions is better. But I found out this undocumented feature and think that maybe needs to be documented? So I opened this issue. Thanks for reply.
That is my point though. I would rather steer people towards using a ruby/gem manager than using this 'feature', for all the reasons listed above.
@knappe I agree with you. Thanks. I will close this and left it undocumented in favor of gem manager.
I think it would be nice to document somewhere. I've found it useful. If I have 5 versions of rake installed and I want to run a command as 0.8.7, rake _0.8.7_ is the way to go, for me. OTOH, anyone curious about how gems are executed will eventually see this code and know.
Documentation should be added to guides somewhere
I am also for documenting this. Saying that this should be left out in favor of Ruby managers doesn't make sense to me.
Thanks! Please document it. : )
This feature is already documented on the Command Reference page, in the section describing the gem install subcommand.
Is it still preferable to create, say, a new page discussing in detail how Rubygems decide which of multiple installed versions of a gem to activate, and mention there also the matter of specifying which version of an executable to use?
I guess it would make sense to add a separate section, right before Command Reference with a general introduction to the gem CLI, including this kind of behaviour that's common to all gem commands?