Skip to content

Fallback to Reline when require 'readline' fails - #1076

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:readline_bundled_gem
Jan 27, 2025
Merged

tompng merged 1 commit into
ruby:masterfrom
tompng:readline_bundled_gem

Conversation

@tompng

@tompng tompng commented Jan 26, 2025

Copy link
Copy Markdown
Member

Require readline may fail because it is a bundled gem in 3.5.0.dev.

Require readline may fail because it is a bundled gem in 3.5.0.dev.
@hsbt hsbt mentioned this pull request Jan 27, 2025
Comment thread lib/irb/input-method.rb
const_set(:Readline, ::Readline)
rescue LoadError
const_set(:Readline, ::Reline)
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adds ReadlineInputMethod::Readline = ::Readline or ::Reline
because we don't want to pollute the top level by adding constant ::Readline when require 'readline' fails.

@tompng
tompng merged commit 1ca7472 into ruby:master Jan 27, 2025
@tompng

tompng commented Jan 27, 2025

Copy link
Copy Markdown
Member Author

To use GNU readline, now we need to add both gem 'readline' and gem 'readline-ext' to Gemfile.

Maybe we can require "readline.#{RbConfig::CONFIG['DLEXT']}" instead of 'readline' (https://github.com/ruby/readline/blob/master/lib/readline.rb)
Then users only need to add readline-ext to Gemfile just as it has been before.

@tompng
tompng deleted the readline_bundled_gem branch January 27, 2025 14:01
@st0012

st0012 commented Jan 27, 2025

Copy link
Copy Markdown
Member

Is there any feature that readline does better than reline? Does it make sense to still allow both types of input methods going forward 🤔

@tompng

tompng commented Jan 27, 2025

Copy link
Copy Markdown
Member Author

I didn't thought of that. Maybe it's time to use Reline also in "--singleline", "--readline", "--legacy" mode.

(Off topic: irb --readline was useful for me to check the difference between Reline and Readline while developing Reline)

@tompng tompng added the bug Something isn't working label Apr 3, 2025
@tompng tompng mentioned this pull request Apr 3, 2025
znz added a commit to rurema/doctree that referenced this pull request Aug 3, 2026
#3408 の残タスク 2 件。

- lib/irb/ext/history.rb は Ruby 3.3.0 で ext/eval_history.rb に改名
  (ruby/irb#623。3.2.9 まで旧名)。history.md に until: "3.3" を付け、
  同内容の eval_history.md(since: "3.3")を新設して文書を引き継ぐ。
  extend-command.md の require も版分岐(3.3 の実装は eval_history を
  参照している)
- IRB::ReadlineInputMethod の include ::Readline は irb 1.15.2 で廃止
  (ruby/irb#1076。const_set 方式+readline 不在時は Reline に
  フォールバック)。Ruby 4.0.0 は irb 1.16.0 を bundled gem として
  同梱するため 4.0 から乖離 → front matter の include を #%until 4.0
  でゲートし、本文の「require 失敗時は定義されない」も版分岐

検証: 境界版(3.2/3.3/4.0)の DB で存否・require・include・
IRB::Context#eval_history の継続を機械確認・checklink 死リンクゼロ。
メソッド単位バッジはライブラリ無視で名前 union のため改名で途切れない。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants