I’m running into an inconsistency between Jruby running on OS X and a production Ubuntu host. On my production host, I have the following:
~ $ 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)'
That is (I believe) valid Ruby code, but more importantly, it seems to be valid jruby code, since it works fine on my OS X box:
~ $ 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 >
Any help fixing this issue would be greatly appreciated!
Solved it! (Worked on it for hours yesterday, solve it 20 minutes after putting it on StackOverflow. The issue is that Jruby defaults to Ruby 1.8 mode for some reason. I’m not entirely sure why it worked at all on my OS X computer, but adding
compat.version=1.9to my.jrubyrcfile did the trick. See: https://github.com/jruby/jruby/wiki/ConfiguringJRuby