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:
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.
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.
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”.
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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.