Portable method of launching another Ruby interpreter

T

Tony Arcieri

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

I'm working on a project that requires a "clean", newly launched Ruby
interpreter to perform a little magic.

I'm looking for a portable way to determine the path to the Ruby interpreter
being used by the current environment. At the very least I'd like for this
to work across Ruby 1.8.7, Ruby 1.9.2, JRuby, and Rubinius.

I've seen people suggest using Config::CONFIG for this, however from what I
can tell this doesn't work on JRuby.

Are there any portable solutions to this problem?
 
J

Joel VanderWerf

I'm working on a project that requires a "clean", newly launched Ruby
interpreter to perform a little magic.

I'm looking for a portable way to determine the path to the Ruby interpreter
being used by the current environment. At the very least I'd like for this
to work across Ruby 1.8.7, Ruby 1.9.2, JRuby, and Rubinius.

I've seen people suggest using Config::CONFIG for this, however from what I
can tell this doesn't work on JRuby.

Are there any portable solutions to this problem?

Doesn't it work on jruby?

$ jruby -v -rrbconfig -e 'p
File.join(*Config::CONFIG.values_at("bindir", "ruby_install_name"))'
jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java
HotSpot(TM) 64-Bit Server VM 1.6.0_20) [amd64-java]
"/usr/local/jruby/bin/jruby"
 
R

Roger Pack

I've seen people suggest using Config::CONFIG for this, however from
what I
can tell this doesn't work on JRuby.

Are there any portable solutions to this problem?

It should work on jruby, unless jruby was run as a jar file (like java
-cp jruby-1.4.9.jar) in which case it won't.

Gem.ruby
is same as os gem's OS.ruby_bin

I would be happy to implement a patch to the os gem to make it work with
jruby from a jar, but it doesn't yet.
-r
 
T

Tony Arcieri

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

Whoops, my bad...

All that said, I think I found a better solution... write a wrapper script
to accomplish what I want and ship it in the gem's bin. Then RubyGems
handles selecting the appropriate Ruby interpreter.

I'm working on a project that requires a "clean", newly launched Ruby
interpreter to perform a little magic.

I'm looking for a portable way to determine the path to the Ruby
interpreter
being used by the current environment. At the very least I'd like for this
to work across Ruby 1.8.7, Ruby 1.9.2, JRuby, and Rubinius.

I've seen people suggest using Config::CONFIG for this, however from what
I
can tell this doesn't work on JRuby.

Are there any portable solutions to this problem?
Doesn't it work on jruby?

$ jruby -v -rrbconfig -e 'p File.join(*Config::CONFIG.values_at("bindir",
"ruby_install_name"))'
jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java
HotSpot(TM) 64-Bit Server VM 1.6.0_20) [amd64-java]
"/usr/local/jruby/bin/jruby"
 
R

Ryan Davis

I'm working on a project that requires a "clean", newly launched Ruby
interpreter to perform a little magic.
=20
I'm looking for a portable way to determine the path to the Ruby = interpreter
being used by the current environment. At the very least I'd like for = this
to work across Ruby 1.8.7, Ruby 1.9.2, JRuby, and Rubinius.
=20
I've seen people suggest using Config::CONFIG for this, however from = what I
can tell this doesn't work on JRuby.
=20
Are there any portable solutions to this problem?

I always use Gem.ruby

I'm not sure if the jruby team has patched that to work for jars or not =
(or if it even needs patching for that matter--I don't use jruby, =
sorry).
 
C

Charles Oliver Nutter

I always use Gem.ruby

I'm not sure if the jruby team has patched that to work for jars or not (=
or if it even needs patching for that matter--I don't use jruby, sorry).

I believe we did modify it at some point:

~/projects/jruby =E2=9E=94 java -jar lib/jruby-complete.jar -rubygems -e "p=
Gem.ruby"
"java -jar /Users/headius/projects/jruby/lib/jruby-complete.jar"
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top