ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "Earlopain (Earlopain _) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "Earlopain (Earlopain _)" <noreply@ruby-lang.org>
Subject: [ruby-core:119915] [Ruby master Bug#20714] Handle optional dependencies in `bundled_gems.rb`
Date: Wed, 13 Nov 2024 13:23:28 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-110636.20241113132328.53314@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20714.20240904141716.53314@ruby-lang.org>

Issue #20714 has been updated by Earlopain (Earlopain _).


https://github.com/ruby/ruby/commit/8cd36a6dab170f4127c58c07b1a388dd3813fb7a removed the first batch of gems from the list of warnings. I agree with it and don't particularly care if these warn a few years after removal, as long as it stops at one point. The warning message is still confusing for future ruby versions though.

The issue I see with your PR is that for one version, they will still warn regardless. So, for a somewhat specific example:
* Some gem `x` requires `fidlde` and handles the potential `LoadError`
* Gem `x` starts to warn on Ruby 3.4, but this gem is already equiped to handle it. The warning is unnecessary
* Other gems loaded after `x` may also require `fiddle` but will not warn since the warning was already emitted
* On Ruby 3.5, gem `x` works and doesn't emit a warning anymore
* However, gems loaded after `x` will error if they failed to declare `fiddle` as their dependency

I guess you could just rely on the multitude of different gemfiles people have and guess that there is someone without gem `x` to report the warning to the other gem author. But I'm unsure if that is a safe bet to make.

I don't think you can properly handle it in `bundled_gems.rb` with what is currently available, the information about if a require should warn or not is simply not there.

----------------------------------------
Bug #20714: Handle optional dependencies in `bundled_gems.rb`
https://bugs.ruby-lang.org/issues/20714#change-110636

* Author: Earlopain (Earlopain _)
* Status: Assigned
* Assignee: hsbt (Hiroshi SHIBATA)
* ruby -v: 3.3.5
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
I've encountered a few places around bundled gems where the library doesn't care if the gem is available, but will still provide some functionallity if it is.

The way to accomplish that right now seems to be by setting `$VERBOSE = nil` and resetting it later again to not bother the user with the warning about the gem. However, this has the effect of silencing the warning about other gems as well, that may not be prepared about the bundling. 

>From `ruby/reline` for example: https://github.com/ruby/reline/blob/c90f08f7e308d2f1cdd7cfaf9939fe45ce546fd2/lib/reline/terminfo.rb#L1-L15
Or the `logging` gem: https://github.com/TwP/logging/blob/df41715364f7eb8c65098cd3c3316677ef1f3784/lib/logging.rb#L9-L15

I propose to simply delay the warning to the next require.

GitHub PR at https://github.com/ruby/ruby/pull/11545



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

  parent reply	other threads:[~2024-11-13 13:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 14:17 [ruby-core:119041] " Earlopain (A S) via ruby-core
2024-09-04 15:51 ` [ruby-core:119042] " Eregon (Benoit Daloze) via ruby-core
2024-09-04 16:06 ` [ruby-core:119043] " Eregon (Benoit Daloze) via ruby-core
2024-09-04 16:20 ` [ruby-core:119044] " Earlopain (A S) via ruby-core
2024-09-04 16:38 ` [ruby-core:119045] " Eregon (Benoit Daloze) via ruby-core
2024-09-04 20:02 ` [ruby-core:119046] " deivid via ruby-core
2024-09-05  6:24 ` [ruby-core:119056] " Earlopain (A S) via ruby-core
2024-09-05  6:26 ` [ruby-core:119057] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-09-26 10:26 ` [ruby-core:119297] " deivid via ruby-core
2024-09-26 10:43 ` [ruby-core:119298] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-09-26 11:05 ` [ruby-core:119299] " Earlopain (A S) via ruby-core
2024-09-26 14:03 ` [ruby-core:119300] " Eregon (Benoit Daloze) via ruby-core
2024-09-26 16:25 ` [ruby-core:119305] " deivid via ruby-core
2024-09-27 11:08 ` [ruby-core:119313] " Earlopain (A S) via ruby-core
2024-09-27 15:34 ` [ruby-core:119323] " Eregon (Benoit Daloze) via ruby-core
2024-09-27 15:59 ` [ruby-core:119324] " deivid via ruby-core
2024-09-28  0:42 ` [ruby-core:119327] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-09-30  8:34 ` [ruby-core:119354] " Earlopain (A S) via ruby-core
2024-09-30  9:11 ` [ruby-core:119355] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-09-30  9:29 ` [ruby-core:119357] " Earlopain (A S) via ruby-core
2024-10-02 20:52 ` [ruby-core:119411] " Eregon (Benoit Daloze) via ruby-core
2024-11-13  5:47 ` [ruby-core:119911] " hsbt (Hiroshi SHIBATA) via ruby-core
2024-11-13  9:12 ` [ruby-core:119913] " deivid via ruby-core
2024-11-13 13:23 ` Earlopain (Earlopain _) via ruby-core [this message]
2024-11-13 14:35 ` [ruby-core:119917] " deivid via ruby-core
2024-11-13 18:05 ` [ruby-core:119920] " Eregon (Benoit Daloze) via ruby-core
2024-11-13 18:15 ` [ruby-core:119921] " Earlopain (Earlopain _) via ruby-core
2024-11-13 18:48 ` [ruby-core:119922] " deivid via ruby-core
2024-11-13 19:42 ` [ruby-core:119923] " Eregon (Benoit Daloze) via ruby-core
2025-02-20 16:44 ` [ruby-core:121134] " deivid via ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-110636.20241113132328.53314@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).