Skip to content

Remove dependency on irb#1649

Closed
Bo98 wants to merge 1 commit intolsegal:mainfrom
Bo98:no-irb-notifier
Closed

Remove dependency on irb#1649
Bo98 wants to merge 1 commit intolsegal:mainfrom
Bo98:no-irb-notifier

Conversation

@Bo98
Copy link
Contributor

@Bo98 Bo98 commented Mar 5, 2026

Description

irb/notifier usage appears to just be debug logs that are never actually activated since they aren't linked up to YARD's own logging system.

The dependency on it therefore seems unnecessary and looks safe to remove, fixing compatibility with Ruby 4.0.

Normally this would only be a problem with the legacy parser but overload tag parsing still unconditionally uses the legacy parser only:

# FIXME: refactor this code to not make use of the Handlers::Base class (tokval_list should be moved)
toks = YARD::Parser::Ruby::Legacy::TokenList.new(args)
args = YARD::Handlers::Ruby::Legacy::Base.new(nil, nil).send(:tokval_list, toks, :all)

Fixes #1636
Fixes #1645

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

@p-linnane
Copy link

@lsegal Apologies for the ping. Would you have a chance to review this PR? Homebrew currently depends on this change for Ruby 4.0 support, and we're pinned to the PR author's fork (one of our lead maintainers) unless this is merged. We'd love to get this upstream.

Comment on lines -18 to -23
DOUT = Notifier::def_notifier("SLex::")
D_WARN = DOUT::def_notifier(1, "Warn: ")
D_DEBUG = DOUT::def_notifier(2, "Debug: ")
D_DETAIL = DOUT::def_notifier(4, "Detail: ")

DOUT.level = Notifier::D_NOMSG
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will almost certainly break downstream users of IRB on Ruby 2.x/3.x if we remove a feature that is advertised by IRB. It seems unlikely, but I would imagine the cleaner approach would be to only disable this behavior if the require fails.

The other approach would be to vendor notifier or otherwise create a mock impl of Notifier.

Copy link
Contributor Author

@Bo98 Bo98 Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll only break (or well "break" in terms of missing debug logging) if they actively required this file within the IRB session and set this private API to enable logging. But couldn't we not just rename the module then? The file is always imported via require_relative for use here so it doesn't need to be called IRB::SLex if we're never using upstream IRB::SLex.

SLex itself was never public API. It was removed in a minor release rather than a major one and went through refactors previously without any backward compatibility.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No break > break.

Yes, we could move the module, that would be a different PR than a no-op refactor IMO. I would accept a refactor that basically vendored SLex as a separate module since we are relying on it. In that module we could do whatever we wanted, including ... not using the SLex code at all.

@lsegal lsegal closed this in 36f0d3c Mar 24, 2026
lsegal added a commit that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please fix your dependencies Add irb as dependency to avoid warning in Ruby v4.0

3 participants