Skip to content

Rescue the LoadError of the ri driver, not only of require 'rdoc' - #1272

Open
hasumikin wants to merge 1 commit into
ruby:masterfrom
hasumikin:rdoc-driver-load-error
Open

hasumikin wants to merge 1 commit into
ruby:masterfrom
hasumikin:rdoc-driver-load-error

Conversation

@hasumikin

Copy link
Copy Markdown
Contributor

Background

I'm working on running IRB on https://github.com/hasumikin/fluxpinel (an implementation of Ruby without the C extensions of CRuby). On Fluxpinel, rdoc loads, but rbs, which rdoc 8.1 requires when it creates the ri driver, needs a C extension and does not load.

The problem in the current IRB

The current RelineInputMethod#rdoc_ri_driver rescues only the LoadError of require 'rdoc', and on LoadError it goes without documentation. But RDoc::RI::Driver.new requires the rest of rdoc, and rdoc 8.1 requires rbs on the path of RDoc::RI::Driver.new. A LoadError raised in RDoc::RI::Driver.new is not rescued, and the moment the completion dialog opens, the LoadError goes up past Reline and the session ends.

The modified IRB

The rescue LoadError covers RDoc::RI::Driver.new too. When the library is missing, there is no documentation, that is, the same handling as when rdoc itself is missing.

With the modified IRB too, the behavior for existing users (environments on CRuby or JRuby where rdoc and rbs are both present) does not change. Unless a LoadError is raised, the modified rescue is not taken.

Test

In an environment where rbs does not load, the modified IRB shows candidates in the completion dialog, shows no documentation, and IRB goes on. In an environment where everything is present, nothing changes.

rdoc_ri_driver rescued the LoadError of `require 'rdoc'` only.
RDoc::RI::Driver.new requires more of rdoc, and rdoc 8.1 requires rbs
there; with a library that is not there, the completion dialog raised
LoadError out of Reline instead of showing no document.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VpVYsAE2Eb17FkqeVd1gKE
@hasumikin
hasumikin requested a review from tompng November 6, 2026 13:05
@hasumikin

Copy link
Copy Markdown
Contributor Author

(One failed test looks not attributable to this patch)

This branch has not been deployed

No deployments
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.

1 participant