From: ruby-core@... Date: 2019-01-03T06:40:54+00:00 Subject: [ruby-core:90868] [Ruby trunk Bug#15500] Behavior of require method in 2.5 is different from 2.4 and 2.6 Issue #15500 has been updated by marcandre (Marc-Andre Lafortune). I was expecting the behavior in 2.5. That's what is correct, right? I tested with `matrix` gem, and 2.4 behaves like 2.5, which is to say it loads the gem only if `gem 'matrix'` is called. Note that 2.4 didn't ship with default `matrix` gem (it was std lib), but it did ship with defaut `bigdecimal` gem. I also realized that it's not possible to load the 0.1.0 `matrix` gem in 2.6.0 because it shipped with that version of the local gem. That in itself is a problem, as the public gem `matrix` v0.1.0 is actually older than the local gem that has shipped with Ruby 2.6.0. I will release v1.0.0 to avoid this issue, and I will have to be careful when mirroring the gem. ---------------------------------------- Bug #15500: Behavior of require method in 2.5 is different from 2.4 and 2.6 https://bugs.ruby-lang.org/issues/15500#change-76055 * Author: mrkn (Kenta Murata) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- On Ruby 2.5, `require 'bigdecimal'` does not load `bigdecimal.so` in gem-installed version of bigdecimal without specifying the version by `gem` method. You can examine this phenomenon by the following code. ```ruby require 'bigdecimal' p $LOADED_FEATURES.grep(/bigdecimal/).first ``` After installing bigdecimal-1.4.2 by `gem install bigdecimal` command, this code (saved as `t.rb`) show the following results: On Ruby 2.4.5 ``` $ ruby-2.4.5 -v t.rb ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-darwin18] "/Users/mrkn/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/bigdecimal-1.4.2/lib/bigdecimal.bundle" ``` On Ruby 2.5.3: ``` $ ruby-2.5.3 -v t.rb ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] "/Users/mrkn/.rbenv/versions/2.5.3/lib/ruby/2.5.0/x86_64-darwin18/bigdecimal.bundle" ``` On Ruby 2.6.0: ``` $ ruby-2.6.0 -v t.rb ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18] "/Users/mrkn/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/bigdecimal-1.4.2/lib/bigdecimal.bundle" ``` On Ruby 2.5.3, with `gem 'bigdecimal', '1.4.2'`, the correct file can be loaded. ``` $ ( echo "gem 'bigdecimal', '1.4.2'"; cat t.rb ) | ruby-2.5.3 -v - ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] "/Users/mrkn/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bigdecimal-1.4.2/lib/bigdecimal.bundle" ``` -- https://bugs.ruby-lang.org/ Unsubscribe: