To reproduce:
require 'mathn'
Error:
LoadError: cannot load such file -- mathn/rational
from ~/.rubies/truffleruby-1.0.0-rc11/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from ~/.rubies/truffleruby-1.0.0-rc11/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `require'
from ~/.rubies/truffleruby-1.0.0-rc11/lib/mri/mathn.rb:49:in `<top (required)>'
from ~/.rubies/truffleruby-1.0.0-rc11/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from ~/.rubies/truffleruby-1.0.0-rc11/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):1
from ~/.rubies/truffleruby-1.0.0-rc11/bin/irb:29:in `<main>'
This issue causes failing running timezone tests => https://github.com/panthomakos/timezone
It looks like we were missing mathn/rational as an actual file, but the functionality is there. But then this is revealed that we're not running mathn specs, and some others that we really should be, so I'm fixing that.
If you want to run that gem right now, try just removing the require statement and you may get further.
Actually it turns out that we have some problems with Ruby-implemented-in-Ruby, where we need a standard divide and we're getting a rational divide.
mathn has been deprecated since Ruby 2.2 and was removed from the standard library in Ruby 2.5 (Source). So I don't think it's worth implementing at all, since we plan to migrate to Ruby 2.5 or Ruby 2.6 soon. Therefore I close this issue.
BTW, the test in the timezone gem is just skipped if mathn is not available:
https://github.com/panthomakos/timezone/blob/fc662ca76e61d91bf4da68d84d57055530c46792/test/timezone/test_mathn_compatibility.rb
@eregon that is not true. It fails due to it. That was the reason why I reported it
@deepj Right, because with TruffleRuby, currently mathn is not correctly detected as "not available".
Good point, let's reopen until that is fixed (i.e., we remove mathn entirely).
Looking at this helped to fix some bugs we had with the specs for other standard libraries, so thanks for that as well 826814cafc2a687788ba4cbd57d481d372d2354f.
I removed mathn in 17aea33a94a8603c7a5abb808eaf127676ff37b6 and improved the spec checking its absence.
Now require 'mathn' raises a LoadError like it does on MRI 2.5+.
@deepj Thank you for the report, and I am sorry to close the issue too early.
@eregon just off-topic
we plan to migrate to Ruby 2.5 or Ruby 2.6 soon
If I could say my opinion, I'd be in Ruby 2.6. Yes, it takes a while to be fully compatible but it'd be great if TruffleRuby would follow always the recent version of Ruby as possible.