# Portable method of launching another Ruby interpreter

**URL:** <https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664>\
**Category:** Ruby\
**Created:** [September 8, 2010, 7:57pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664 "2010-09-08T19:57:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 8, 2010, 7:57pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/1 "2010-09-08T19:57:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 8, 2010, 8:59pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/2 "2010-09-08T20:59:43Z")

</div>

On 09/08/2010 10:56 AM, Tony A. wrote:

> 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™ 64-Bit Server VM 1.6.0\_20) [amd64-java]  
“/usr/local/jruby/bin/jruby”

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 8, 2010, 10:08pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/3 "2010-09-08T22:08:43Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 8, 2010, 10:31pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/4 "2010-09-08T22:31:39Z")

</div>

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.

On Wed, Sep 8, 2010 at 12:58 PM, Joel VanderWerf

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 9, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/5 "2010-09-09T16:34:05Z")

</div>

On Wed, Sep 8, 2010 at 9:07 PM, Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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 âž” java -jar lib/jruby-complete.jar -rubygems -e “p  
Gem.ruby”  
“java -jar /Users/headius/projects/jruby/lib/jruby-complete.jar”

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [September 8, 2010, 11:08pm UTC](https://www.ruby-forum.com/t/portable-method-of-launching-another-ruby-interpreter/194664/6 "2010-09-08T23:08:32Z")

</div>

On Sep 8, 2010, at 10:56 , Tony A. wrote:

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