# Running two versions of Ruby - Lessons Learned

**URL:** <https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824>\
**Category:** Ruby\
**Created:** [February 21, 2010, 2:50am UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824 "2010-02-21T02:50:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 21, 2010, 2:50am UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824/1 "2010-02-21T02:50:40Z")

</div>

After experimenting with Ruby 1.9 I’ve found I really like it and wanted  
to make it my main version of Ruby. My problem was that I have two  
programs that I use frequently that only work with Ruby 1.8. I want my  
programs to run just by clicking the icons on my Windows desktop.  
However, when setting the default application for an icon, Windows  
forces you to choose between running all the .rb programs using either  
1.9 or 1.8 (you can’t set some to default to 1.9 and others to default  
with 1.8 as far as I can tell).

I was trying to figure out how to get around this, and hit upon the  
following:

- I set Ruby 1.9 as the default program for all my .rb icons on my  
desktop.

- For thos few programs that need to run under Ruby 1.8 I wrote a simple  
ruby script that calls the Kernel.system method:

system( “C:\Ruby\bin\rubyw.exe my\_Ruby1.8\_program.rb” )

I run this script in Ruby 1.9, but the system method executes the target  
program using Ruby 1.8. I have the icon for this script on my desktop,  
rather than the icon for the actual 1.8 program. Thus, it is  
transparent to me whether, when I click on an icon, it runs in Ruby 1.8  
or in Ruby 1.9.

It seems to work fine. However, if others have a more elegant or better  
solution, or can see potential problems with this solution, I would be  
interested in hearing about it.

Thanks.

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 21, 2010, 5:20am UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824/2 "2010-02-21T05:20:57Z")

</div>

On Feb 20, 2010, at 5:50 PM, Alex DeCaria  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - For thos few programs that need to run under Ruby 1.8 I wrote a  
> simple  
> ruby script that calls the Kernel.system method:
> 
> system( “C:\Ruby\bin\rubyw.exe my\_Ruby1.8\_program.rb” )

You should use exec instead. system runs the script as a sub process  
with your wrapper just sitting in memory waiting for it to exit. exec  
replaces your wrapper with the called script.

-Dane

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 21, 2010, 1:23pm UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824/3 "2010-02-21T13:23:56Z")

</div>

Alex DeCaria wrote:

> After experimenting with Ruby 1.9 I’ve found I really like it and wanted  
> to make it my main version of Ruby. My problem was that I have two  
> programs that I use frequently that only work with Ruby 1.8. I want my  
> programs to run just by clicking the icons on my Windows desktop.  
> However, when setting the default application for an icon, Windows  
> forces you to choose between running all the .rb programs using either  
> 1.9 or 1.8 (you can’t set some to default to 1.9 and others to default  
> with 1.8 as far as I can tell).(…)

> –Alex

If you have (or create) on your desktop a shortcut to your .rb file, you  
can edit the properties of this shortcut. On the tab “shortcut” the  
entry “target” will contain the path to your .rb file. Modify this to:  
“path\to\ruby1.8\bin\ruby.exe path\to\rb”.

hth,

Siep

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 21, 2010, 1:25pm UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824/4 "2010-02-21T13:25:17Z")

</div>

Dane J. wrote:

> On Feb 20, 2010, at 5:50 PM, Alex DeCaria  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > - For thos few programs that need to run under Ruby 1.8 I wrote a  
> > simple  
> > ruby script that calls the Kernel.system method:
> > 
> > system( “C:\Ruby\bin\rubyw.exe my\_Ruby1.8\_program.rb” )
> 
> You should use exec instead. system runs the script as a sub process  
> with your wrapper just sitting in memory waiting for it to exit. exec  
> replaces your wrapper with the called script.
> 
> -Dane

Thanks. I was wondering what the difference between system and exec  
was. That helps.

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 21, 2010, 2:40pm UTC](https://www.ruby-forum.com/t/running-two-versions-of-ruby-lessons-learned/183824/5 "2010-02-21T14:40:55Z")

</div>

> If you have (or create) on your desktop a shortcut to your .rb file, you  
> can edit the properties of this shortcut. On the tab “shortcut” the  
> entry “target” will contain the path to your .rb file. Modify this to:  
> “path\to\ruby1.8\bin\ruby.exe path\to\rb”.
> 
> hth,
> 
> Siep

I thought there must be a way to do it without writing a separate  
script. Thanks. --Alex
