2012-10-19 49 views
0

我遇到在OS X和Ubuntu的生產主機上運行的JRuby之間的不一致。在我的生產主機,我有以下幾點:奇怪的語法錯誤不一致JRuby中

~ $ java -version 
java version "1.6.0_22" 
Java(TM) SE Runtime Environment (build 1.6.0_22-b04) 
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode) 
~ $ rvm use jruby-1.6.8 
Using /home/ubuntu/.rvm/gems/jruby-1.6.8 
~ $ rvm list rubies 

rvm rubies 

=> jruby-1.6.8 [ x86_64 ] 
* ruby-1.9.2-p318 [ x86_64 ] 

# => - current 
# =* - current && default 
# * - default 

~ $ irb 
jruby-1.6.8 :001 > def foo(*args) 
jruby-1.6.8 :002?> end 
=> nil 
jruby-1.6.8 :003 > foo(1, 
jruby-1.6.8 :004 >   2, 
jruby-1.6.8 :005 >  ) 
SyntaxError: (irb):5: syntax error, unexpected tRPAREN 

    ) 
    ^
    from org/jruby/RubyKernel.java:1112:in `eval' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:158:in `eval_input' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:271:in `signal_status' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:155:in `eval_input' 
    from org/jruby/RubyKernel.java:1439:in `loop' 
    from org/jruby/RubyKernel.java:1212:in `catch' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:154:in `eval_input' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:71:in `start' 
    from org/jruby/RubyKernel.java:1212:in `catch' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/lib/ruby/1.8/irb.rb:70:in `start' 
    from /home/ubuntu/.rvm/rubies/jruby-1.6.8/bin/irb:17:in `(root)' 

這是(我相信)有效的Ruby代碼,但更重要的是,它似乎是有效的JRuby的代碼,因爲它適用於我的OS X框細:

~ $ java -version 
java version "1.6.0_35" 
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811) 
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode) 
~ $ rvm use jruby-1.6.8 
Using /Users/lwiman/.rvm/gems/jruby-1.6.8 
~ $ rvm list rubies 

rvm rubies 

    jruby-1.6.4 [ x86_64 ] 
    jruby-1.6.7 [ x86_64 ] 
=> jruby-1.6.8 [ x86_64 ] 
* ruby-1.9.2-p290 [ x86_64 ] 
    ruby-1.9.3-p194 [ x86_64 ] 

# => - current 
# =* - current && default 
# * - default 

~ $ irb 
jruby-1.6.8 :001 > def foo(*args) 
jruby-1.6.8 :002?> end 
=> nil 
jruby-1.6.8 :003 > foo(1, 
jruby-1.6.8 :004 >   2, 
jruby-1.6.8 :005 >  ) 
=> nil 
jruby-1.6.8 :006 > 

解決此問題的任何幫助將不勝感激!

回答

2

解決它! (在昨天工作了好幾個小時,在把它放到StackOverflow上20分鐘後解決了它,問題是由於某種原因,Jruby默認爲Ruby 1.8模式,我不完全確定它爲什麼在我的OS X計算機上工作,但是加入compat.version=1.9.jrubyrc文件的伎倆見:https://github.com/jruby/jruby/wiki/ConfiguringJRuby

+0

的JRuby 1.7.0吼叫默認情況下是在1.8模式下,從1.7.0 JRuby的將默認爲1.9模式 – mpapis

+0

默認在1.9模式下安裝JRuby: 'RVM安裝JRuby -C -Djruby.default.ruby.version = 1.9' http://samuel.kadolph.com/2011/10/jruby-with-1-9-mode-as-the-default-with- rvm/ – RecursivelyIronic

+1

rm有一個快捷方式,適用於jruby和rbx:'rvm install jruby --1.9' – mpapis