guides icon indicating copy to clipboard operation
guides copied to clipboard

Use different gem version on command line

Open JuanitoFatas opened this issue 12 years ago • 16 comments

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!

JuanitoFatas avatar Apr 08 '14 11:04 JuanitoFatas

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.

knappe avatar Apr 09 '14 04:04 knappe

Thanks for the heads up, @knappe. You're right!

JuanitoFatas avatar Apr 09 '14 05:04 JuanitoFatas

I think it's documented somewhere, but it isn't a hack.

I will check.

drbrain avatar Apr 09 '14 06:04 drbrain

I don't think I've seen documentation for it. But its logic is included in all installed gem executables

bf4 avatar Apr 10 '14 14:04 bf4

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.

JuanitoFatas avatar Apr 18 '14 18:04 JuanitoFatas

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 avatar Apr 18 '14 18:04 knappe

@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.

JuanitoFatas avatar Apr 18 '14 18:04 JuanitoFatas

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 avatar Apr 18 '14 18:04 knappe

@knappe I agree with you. Thanks. I will close this and left it undocumented in favor of gem manager.

JuanitoFatas avatar Apr 18 '14 18:04 JuanitoFatas

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.

bf4 avatar Apr 18 '14 20:04 bf4

Documentation should be added to guides somewhere

drbrain avatar Apr 18 '14 21:04 drbrain

I am also for documenting this. Saying that this should be left out in favor of Ruby managers doesn't make sense to me.

strzibny avatar May 04 '14 21:05 strzibny

Thanks! Please document it. : )

JuanitoFatas avatar May 05 '14 03:05 JuanitoFatas

This feature is already documented on the Command Reference page, in the section describing the gem install subcommand.

igneus avatar Oct 17 '20 21:10 igneus

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?

igneus avatar Oct 17 '20 23:10 igneus

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?

deivid-rodriguez avatar Oct 19 '20 12:10 deivid-rodriguez