irb(main):001:0> test = (0/1).rationalize
=> (0/1)
irb(main):002:0> test.to_i
NoMethodError: undefined method `to_i' for (0/1):Rational
from (irb):2:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from C:\Development\jruby-1.6.4\bin\irb:13:in `(root)'
irb(main):003:0>
This works in JRuby 1.6.4 when installed normally, but after having built from source I get the error.
This is a bug in JRuby.
https://jira.codehaus.org/browse/JRUBY-6142
The ticket includes a fix but it has not been merged.
If like me, you were only encountering this problem when installing gems, try making sure you aren’t running with the –debug flag. If you’re having this problem using a JRuby installation you built from source, try the precompiled version from the website.