How to make JRuby 1.6 default to Ruby 1.9?

前端 未结 6 1768
北海茫月
北海茫月 2020-12-02 05:26

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

<
相关标签:
6条回答
  • 2020-12-02 05:34

    RVM allows now building JRuby/Rubinius with default mode set by default:

    rvm install jruby-1.6.7-d19 --1.9
    rvm install rbx-2.0.testing-d19 --1.9
    

    The suffix -d19 can be omitted, I use it only to distinguish between 1.8 and 1.9 mode rubies.

    The --1.9 mode will become the default in next major releases of JRuby/Rubinius, so you can make sure you will use 1.8 with --1.8 rvm switch.

    UPDATE 2012-05-25: Jruby 1.7.0.preview1 is out, it is 1.9 by default!

    0 讨论(0)
  • 2020-12-02 05:41

    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...
    
    0 讨论(0)
  • 2020-12-02 05:45

    In Windows, use set JRUBY_OPTS=--1.9 instead.

    0 讨论(0)
  • 2020-12-02 05:46

    If you're creating jruby from java:

    RubyInstanceConfig config = new RubyInstanceConfig();   
    config.setCompatVersion(CompatVersion.Ruby1_9); 
    Ruby runtime = Ruby.newInstance(config)
    

    (Thanks to bbrowning on the #jrubyc irc channel)

    0 讨论(0)
  • 2020-12-02 05:53

    When using warbler to package an app as a war file, the version can be set by running:

    warble config
    

    which creates a config/warble.rb file. This file contains lots of comments on how to configure warbler, and in particular:

      # Set JRuby to run in 1.9 mode.
      # config.webxml.jruby.compat.version = "1.9"
    

    Uncomment the second line by removing the #, and re-package your war with the warble command.

    0 讨论(0)
  • 2020-12-02 05:54

    An alternative solution is to put the following line (and other settings) in your ~/.jrubyrc file

    compat.version=1.9
    
    0 讨论(0)
提交回复
热议问题