How to make JRuby 1.6 default to Ruby 1.9?

arkadiy picture arkadiy · Jan 21, 2011 · Viewed 27.2k times · Source

what is the best way to make JRuby to run in 1.9 mode by default?

i.e, I want to run rake test instead of jruby --1.9 -S rake test

Thank you

Answer

toddsundsted picture toddsundsted · Jan 21, 2011

Use the JRUBY_OPTS environment variable. JRUBY_OPTS holds a list of arguments that are added to any arguments specified on the command line.

For example (on Linux):

$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSp...
$ export JRUBY_OPTS=--1.9
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.9.2 trunk 136) (2011-01-10 769f847) (Java HotSpot(TM...
$ export JRUBY_OPTS=--1.8
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSpo...