Project

General

Profile

Actions

Bug #19885

closed

Invalid Warning for Default Gems That Will Move to Bundled Gems

Added by jeremyevans0 (Jeremy Evans) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.3.0preview2 (2023-09-14 master e50fcca9a7) [x86_64-openbsd]
[ruby-core:114782]

Description

Starting in ruby 3.3.0-preview2, attempting to require bigdecimal, mutex_m, base64, or other libraries that will move to bundled gems in Ruby 3.4.0 results in a warning, even when bundler is not in use:

$ ruby33 -v -r bigdecimal -e ''
ruby 3.3.0preview2 (2023-09-14 master e50fcca9a7) [x86_64-openbsd]
warning: bigdecimal which will be not part of the default gems since Ruby 3.4.0

I think such warnings are bugs if bundler is not in use. When a library is moved from a default gem to a bundled gem, such code will work fine if not using bundler. It is only when using bundler where such code would have problems, and therefore, if Ruby warns at all, it should only warn when bundler is in use.

The only time such a warning would make sense if bundler is not in use is if the library was not going to be a bundled gem. In that case, first the library should be moved from a default gem to a bundled gem, then the bundled gem that ships with Ruby should provide the warning, which you can avoid by installing an updated gem version.

Note that you also get the warning when loading a gem that has bigdecimal as a runtime dependency (this example uses Sequel 5.72.0, which has a runtime dependency on bigdecimal as you can see at https://rubygems.org/gems/sequel/versions/5.72.0):

$ ruby33 -v -r sequel -e ''
ruby 3.3.0preview2 (2023-09-14 master e50fcca9a7) [x86_64-openbsd]
/usr/local/lib/ruby/gems/3.3/gems/sequel-5.72.0/lib/sequel/core.rb:3: warning: bigdecimal which will be not part of the default gems since Ruby 3.4.0

This warning makes even less sense, because even if bigdecimal was removed as both a default gem and a bundled gem, installing Sequel 5.72.0 would install bigdecimal as a dependency.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #19776: Warn bundled gems when it called from `require`Closedhsbt (Hiroshi SHIBATA)Actions

Updated by mame (Yusuke Endoh) over 1 year ago

  • Status changed from Open to Assigned

Agreed. I think the warning is good only when bundler is used.

@hsbt (Hiroshi SHIBATA) How about https://github.com/ruby/ruby/pull/8457 ?

Actions #2

Updated by Eregon (Benoit Daloze) over 1 year ago

  • Related to Feature #19776: Warn bundled gems when it called from `require` added

Updated by hsbt (Hiroshi SHIBATA) about 1 year ago

@jeremyevans0 (Jeremy Evans) Thanks.

I'm considering to skip this warning from rubygems. I think we should only warn it if environment didn't have gem like webrick.

Note that you also get the warning when loading a gem that has bigdecimal as a runtime dependency (this example uses Sequel 5.72.0, which has a runtime dependency on bigdecimal as you can see at https://rubygems.org/gems/sequel/versions/5.72.0):

I could reproduce that. It's a bug.

$ gem info bigdecimal

*** LOCAL GEMS ***

bigdecimal (3.1.4)
    Authors: Kenta Murata, Zachary Scott, Shigeo Kobayashi
    Homepage: https://github.com/ruby/bigdecimal
    Licenses: Ruby, BSD-2-Clause
    Installed at (default): /Users/hiroshi.shibata/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0

    Arbitrary-precision decimal floating-point number library.
~
$ ruby -v -r bigdecimal -e ''
ruby 3.3.0dev (2023-09-23T07:34:20Z master d80002c902) +YJIT [arm64-darwin22]
warning: bigdecimal which will be not part of the default gems since Ruby 3.4.0
~
$ gem i bigdecimal
Fetching bigdecimal-3.1.4.gem
Building native extensions. This could take a while...
    exists /Users/hiroshi.shibata/Documents/github.com/ruby/bigdecimal
Successfully installed bigdecimal-3.1.4
1 gem installed
~
$ gem info bigdecimal

*** LOCAL GEMS ***

bigdecimal (3.1.4)
    Authors: Kenta Murata, Zachary Scott, Shigeo Kobayashi
    Homepage: https://github.com/ruby/bigdecimal
    Licenses: Ruby, BSD-2-Clause
    Installed at: /Users/hiroshi.shibata/.local/share/gem

    Arbitrary-precision decimal floating-point number library.
~
$ ruby -v -r bigdecimal -e ''
ruby 3.3.0dev (2023-09-23T07:34:20Z master d80002c902) +YJIT [arm64-darwin22]
warning: bigdecimal which will be not part of the default gems since Ruby 3.4.0

When user did install default gems via rubygems.org like above, we shouldn't warn that.

Updated by Dan0042 (Daniel DeLorme) about 1 year ago

I'm confused by this warning "bigdecimal which will be not part of the default gems since Ruby 3.4.0"

Besides being grammatically incorrect, this tells me nothing about what is the problem, why is this a problem, or how I should fix it. I think warnings should provide a bit more actionable insight.

Even with the context I can read in this ticket, I have no idea why a require of a soon-to-be-bundled gem is a problem.

Updated by hsbt (Hiroshi SHIBATA) about 1 year ago

  • Status changed from Assigned to Closed

I changed this warning feature only for LoadError at https://github.com/ruby/ruby/pull/8636.

The current behavior is here:

$ ruby -v -r bigdecimal -e ''
ruby 3.3.0dev (2023-10-13T07:22:09Z master 35edc14ee1) +YJIT [arm64-darwin23]

$ ruby -v -r webrick -e ''
ruby 3.3.0dev (2023-10-13T07:22:09Z master 35edc14ee1) +YJIT [arm64-darwin23]
webrick which is not part of the default gems since Ruby 3.0.0. Install webrick from RubyGems.
<internal:/Users/hsbt/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:128:in `require': cannot load such file -- webrick (LoadError)
        from <internal:/Users/hsbt/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/rubygems/core_ext/kernel_require.rb>:128:in `require'

Updated by Dan0042 (Daniel DeLorme) about 1 year ago

Thank you, that's much clearer.

If you want to make it perfect maybe just tweak the grammar:
"webrick is not part of the default gems since Ruby 3.0.0"
"webrick will no longer be part of the default gems in Ruby 3.0.0"

Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0