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

Stop treating history-saving logic as extension #613

Merged
merged 1 commit into from Jul 3, 2023

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jun 25, 2023

Since IRB.conf[:SAVE_HISTORY] is assigned with 1000 by default, history-saving is a feature enabled by default. So it should not be treated as an extension, which adds unnecessary complexity to the code.

(I plan to rename ext/history to ext/eval_history later as it's a different feature)

Since `IRB.conf[:SAVE_HISTORY]` is assigned with 1000 by default, history-saving
is a feature enabled by default. So it should not be treated as an extension,
which adds unnecessary complexity to the code.
@st0012 st0012 self-assigned this Jun 25, 2023
@st0012 st0012 requested a review from a team June 27, 2023 10:22
@tompng tompng merged commit f3d54aa into master Jul 3, 2023
47 checks passed
@tompng tompng deleted the consolidate-history-saving-logic branch July 3, 2023 13:48
matzbot pushed a commit to ruby/ruby that referenced this pull request Jul 3, 2023
(ruby/irb#613)

Since `IRB.conf[:SAVE_HISTORY]` is assigned with 1000 by default, history-saving
is a feature enabled by default. So it should not be treated as an extension,
which adds unnecessary complexity to the code.
@eregon
Copy link
Member

eregon commented Feb 15, 2024

I have this in my ~/.irbrc:

require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 1000

On Ruby 3.3.0, now irb warns like this:

$ irb          
Error loading RC file '/home/eregon/.irbrc':
<internal:/home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require': cannot load such file -- irb/ext/save-history (LoadError)
Did you mean?  irb/ext/eval_history
	from <internal:/home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
	from /home/eregon/.irbrc:2:in `<top (required)>'
	from /home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/irb/init.rb:399:in `load'
	from /home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/irb/init.rb:399:in `run_config'
	from /home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/irb/init.rb:49:in `setup'
	from /home/eregon/.rubies/ruby-3.3.0/lib/ruby/3.3.0/irb.rb:896:in `start'
	from /home/eregon/.rubies/ruby-3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.0/exe/irb:9:in `<top (required)>'
	from /home/eregon/.rubies/ruby-3.3.0/bin/irb:25:in `load'
	from /home/eregon/.rubies/ruby-3.3.0/bin/irb:25:in `<main>'
irb(main):001> 

There is no issue on Ruby < 3.3, e.g. it works fine on Ruby 3.2.2 (with the irb shipped with that Ruby release).

What is a good solution to ensure history is enabled both on 3.3.0 (where it's default) and on older versions?

Maybe I just remove the last 2 lines? Since when is SAVE_HISTORY 1000 by default?
Also is require 'irb/completion' still non-default or I can also remove that?

@st0012
Copy link
Member Author

st0012 commented Feb 15, 2024

I think this is similar to #804

Since as early as IRB 0.9.6, require 'irb/ext/save-history' has become obsolete as specifying IRB.conf[:SAVE_HISTORY] = 1000 would already load it. So you can simply remove that require and it should still work for both Ruby 3.2 and 3.3 (even 3.1 or 3.0 I guess).

Also is require 'irb/completion' still non-default or I can also remove that?

Yeah you can remove it as it's required by default since Ruby 2.7 (IRB 1.2.6)

holman added a commit to holman/dotfiles that referenced this pull request Apr 6, 2024
weird one to track down, but:
ruby/irb#613
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.

None yet

3 participants