Specifying Ruby Version from Command Line

A

Alex DeCaria

I have two versions of Ruby installed (1.8 and 1.9). When starting a
Ruby script from the command window, how do I specify which version of
Ruby I want to use? I'm assuming there is some option for this that I
can set, but I don't know what it is.

--Alex
 
H

Hassan Schroeder

I have two versions of Ruby installed (1.8 and 1.9). =A0When starting a
Ruby script from the command window, how do I specify which version of
Ruby I want to use?

Use the full path, or change your PATH environment variable to put
the one you want to use first.

--=20
Hassan Schroeder ------------------------ (e-mail address removed)
twitter: @hassan
 
J

Joel VanderWerf

Alex said:
I have two versions of Ruby installed (1.8 and 1.9). When starting a
Ruby script from the command window, how do I specify which version of
Ruby I want to use? I'm assuming there is some option for this that I
can set, but I don't know what it is.

One way is to build with the --program-suffix option:

$ ./configure --help | grep suffix
--program-suffix=SUFFIX append SUFFIX to installed program
names

I usually build 1.8 normally, and build 1.9 with

--program-suffix=19

Remember to use gem19 to install gems for 1.9.
 
E

Eustáquio Rangel

2010/2/20 Alex DeCaria said:
I have two versions of Ruby installed (1.8 and 1.9). =A0When starting a
Ruby script from the command window, how do I specify which version of
Ruby I want to use? =A0 I'm assuming there is some option for this that I
can set, but I don't know what it is.

What OS are you running, and how did you install both versions?
 
S

Shane Emmons

I wrote a script that I can call that changes my path. I run 'setruby 1.8'
to change the path to 1.8, 'setruby 1.9' to change the path to 1.9 and I
also have 'setruby jruby' to change to jruby.

On Sat, Feb 20, 2010 at 2:57 PM, Eust=E1quio Rangel <eustaquiorangel@gmail.=
com
What OS are you running, and how did you install both versions?


--=20
Shane Emmons
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

I have two versions of Ruby installed (1.8 and 1.9). When starting a
Ruby script from the command window, how do I specify which version of
Ruby I want to use? I'm assuming there is some option for this that I
can set, but I don't know what it is.

--Alex
I've found that rvm handles this beautifully.
example: http://i48.tinypic.com/2ng8mlu.png
website: http://rvm.beginrescueend.com/
if you're using textmate: http://rheimbuch.posterous.com/rvm-and-textmate

Each version also maintains it's own rubygems.
 
A

Alex DeCaria

Eustáquio Rangel said:
What OS are you running, and how did you install both versions?

I am using Windows 7 Professional (64-bit). I previously had Ruby 1.8.6
installed using the old 1-click installer. I then installed Ruby 1.9
using the windows installer found at RubyIntaller.org.

The Ruby 1.9 is automatically installed in a different directory
(C:\Ruby19 instead of C:\Ruby) so the two installs are independent. I
have made Ruby 1.9 the default (it is the only one in my Path). So, as
was suggested earlier, to run a Ruby 1.8 program I just issue the
command 'C:\Ruby\bin myprogram.rb'. To run a Ruby 1.9 program I just
do 'ruby my program.rb'

It is working great. Thanks everyone!

--Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top