[jruby-user] Behavior of 'system'. Jruby 1.5.3

1 view
Skip to first unread message

Bob Whiteside

unread,
Oct 6, 2010, 7:05:10 PM10/6/10
to us...@jruby.codehaus.org
Hi All,

When I run the command:

    jruby -e "system '/usr/bin/ruby -v'"

the version output I see is from JRuby, rather that the Ruby that I expected.  I suspect that this is related to some optimization used to avoid launching new JVM's, or to make "Ruby" code work with "JRuby."

My question is, "How do I turn this off?"  I actually, really, want to run /usr/bin/ruby, and I've expressed that as clearly as I know how in the code.  My current hack is to write a little shell script (without 'ruby' in its filename!) and route the call through that, but that is really awkward.  Can I make JRuby run the actual command I tell it to?

Cheers,
--Bob

Wayne Meissner

unread,
Oct 6, 2010, 8:11:02 PM10/6/10
to us...@jruby.codehaus.org
See if system '/usr/bin/env ruby -v' works. That might confound the
jruby heuristics, and run the real ruby. Or you could try '/bin/sh
-c' instead of /usr/bin/env.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Hirotsugu Asari

unread,
Oct 6, 2010, 8:54:14 PM10/6/10
to us...@jruby.codehaus.org
I believe this is a known issue: see http://bugs.jruby.org/5110

Bob Whiteside

unread,
Oct 7, 2010, 12:10:07 PM10/7/10
to us...@jruby.codehaus.org
Oh, Thanks, Wayne!  That worked!

Thanks, also, to Hirotsugu, but that appears to be a different issue.  My "system" command ran fine, it just ran teh wrong program. 

Cheers,
--Bob

Roger Pack

unread,
Oct 7, 2010, 6:06:36 PM10/7/10
to us...@jruby.codehaus.org
Bob Whiteside wrote:
> Hi All,
>
> When I run the command:
>
> jruby -e "system '/usr/bin/ruby -v'"
>
> the version output I see is from JRuby, rather that the Ruby that I
> expected. I suspect that this is related to some optimization used to
> avoid
> launching new JVM's, or to make "Ruby" code work with "JRuby."

Perhaps related to:

http://www.ruby-forum.com/topic/204508

?

(+1 for wishing the default of inproc were false--it's quite surprising
when you run into these bugs...)
--
Posted via http://www.ruby-forum.com/.

Bob Whiteside

unread,
Oct 7, 2010, 7:03:20 PM10/7/10
to us...@jruby.codehaus.org
Oh, thanks, Roger.  That is, indeed related.  Further more, reading over there, I learned about
jruby.launch.inproc=true
I did not know about this setting.  I will now go play with it! 

And, yes.  This was an expensive-in-time learning experience.  I understand why it was done, but still...


Cheers,
--Bob
Reply all
Reply to author
Forward
0 new messages