Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to Reline when require 'readline' fails #1076

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

tompng
Copy link
Member

@tompng tompng commented Jan 26, 2025

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
const_set(:Readline, ::Readline)
rescue LoadError
const_set(:Readline, ::Reline)
end
Copy link
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
33 checks passed
@tompng
Copy link
Member Author

tompng commented Jan 27, 2025

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
Copy link
Member

st0012 commented Jan 27, 2025

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
Copy link
Member Author

tompng commented Jan 27, 2025

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants