Specifying 1.9 mode with JRuby and rbenv

I have 2 applications that must run JRuby 1.6.5 in 1.8 mode, and the other to run JRuby 1.6.7 in 1.9 mode. Is it possible to indicate in the application that I want one application to start in 1.9 mode without the need to explicitly set the JRUBY_OPTS environment variable. Inside .rvmrc, I could do the following:

proj_1_8 version of .rvmrc
unset JRUBY_OPTS
rvm use jruby-1.6.5@proj_1_8

proj_1_9 version of .rvmrc
export JRUBY_OPTS=--1.9
rvm use jruby-1.6.7@proj_1_9

In any case, can I automatically get the set mode without having to manually set / turn off the environment variable whenever I switch between projects?

+5
source share
2 answers

As suggested by D3mon-1stVFW ...

https://github.com/sstephenson/rbenv-vars will help.

$ ruby-app-dir> jruby --version
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.6.0_33) [darwin-i386-java]

$ ruby-app-dir> ## Install rbenv-vars as indicated in Github

$ ruby-app-dir> cat .rbenv-vars
JRUBY_OPTS=--1.9

$ ruby-app-dir> jruby --version
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.6.0_33) [darwin-i386-java]
+3
source

chruby.

$ chruby jruby --1.9
$ jruby --version
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.7.0_09-icedtea-mockbuild_2012_10_17_15_53-b00 [linux-amd64]
$ chruby jruby --1.8
jruby 1.7.0 (ruby-1.8.7p370) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.7.0_09-icedtea-mockbuild_2012_10_17_15_53-b00 [linux-amd64]
0

All Articles