我遇到了在 OS X 上运行的 Jruby 和生产 Ubuntu 主机之间的不一致。在我的生产主机上,我有以下内容:
~ $ 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 >
任何解决此问题的帮助将不胜感激!