Skip to content

Stop treating history-saving logic as extension#613

Merged
tompng merged 1 commit into
masterfrom
consolidate-history-saving-logic
Jul 3, 2023
Merged

Stop treating history-saving logic as extension#613
tompng merged 1 commit into
masterfrom
consolidate-history-saving-logic

Conversation

@st0012

@st0012 st0012 commented Jun 25, 2023

Copy link
Copy Markdown
Member

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
@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

eregon commented Feb 15, 2024

Copy link
Copy Markdown
Member

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

st0012 commented Feb 15, 2024

Copy link
Copy Markdown
Member Author

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
javierjulio added a commit to javierjulio/laptop that referenced this pull request Jun 13, 2024
tyriker pushed a commit to tyriker/dotfiles that referenced this pull request Sep 14, 2024
weird one to track down, but:
ruby/irb#613
apuertolas pushed a commit to apuertolas/dotfiles that referenced this pull request Oct 6, 2024
weird one to track down, but:
ruby/irb#613
pmeinhardt pushed a commit to pmeinhardt/dotfiles that referenced this pull request Dec 30, 2024
weird one to track down, but:
ruby/irb#613
JonCrawford pushed a commit to JonCrawford/dotfiles that referenced this pull request Apr 12, 2025
weird one to track down, but:
ruby/irb#613
JonCrawford pushed a commit to JonCrawford/dotfiles that referenced this pull request Apr 12, 2025
weird one to track down, but:
ruby/irb#613
lukecartledge pushed a commit to lukecartledge/dotfiles that referenced this pull request Nov 12, 2025
weird one to track down, but:
ruby/irb#613
asierzapata pushed a commit to asierzapata/dotfiles that referenced this pull request Apr 15, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants