Project

General

Profile

Bug #7679

IRB history is broken

Added by zzak (Zachary Scott) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:51347]

Description

steps to reproduce:
$ irb
irb(main):001:> 1 + 2
=> 3
irb(main):002:0> exit
$ irb
irb(main):001:0> up arrow nothing

I should see at least "1 + 2" when I hit the up arrow.

Using: ruby 2.0.0dev (2012-12-30 trunk 38663) [x86_64-linux]

Also confirmed on: ruby 2.0.0dev (2013-01-07 trunk 38734) [x86_64-darwin12.2.0]

Associated revisions

Revision 39049
Added by zzak (Zachary Scott) about 4 years ago

  • lib/irb.rb, lib/irb/ext/save-history.rb: Add documentation on how to enabled irb history [Bug #7679]

Revision 39049
Added by zzak (Zachary Scott) about 4 years ago

  • lib/irb.rb, lib/irb/ext/save-history.rb: Add documentation on how to enabled irb history [Bug #7679]

Revision 39049
Added by zzak (Zachary Scott) about 4 years ago

  • lib/irb.rb, lib/irb/ext/save-history.rb: Add documentation on how to enabled irb history [Bug #7679]

Revision 39049
Added by zzak (Zachary Scott) about 4 years ago

  • lib/irb.rb, lib/irb/ext/save-history.rb: Add documentation on how to enabled irb history [Bug #7679]

History

#1 [ruby-core:51352] Updated by zzak (Zachary Scott) over 4 years ago

  • Status changed from Open to Assigned

#2 [ruby-core:51357] Updated by injekt (Lee Jarvis) over 4 years ago

I also tried with the following:

bin/irb -rirb/ext/save-history

But with the same outcome.

#3 [ruby-core:51380] Updated by injekt (Lee Jarvis) over 4 years ago

I shouldn't also note that I'm having this issue on 1.9.3 and have always had it on 1.9.3, can anyone reproduce this on that version or anything earlier?

bin/irb -rirb/ext/save-history
irb(main):001:0> 1 + 2
=> 3
irb(main):002:0> quit
bin/irb -rirb/ext/save-history
irb(main):001:0> up arrow nothing..
irb(main):001:0> RUBY_DESCRIPTION
=> "ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]"

#4 [ruby-core:51381] Updated by no6v (Nobuhiro IMAI) over 4 years ago

=begin
You need to set IRB.conf[:SAVE_HISTORY] how many lines you want to save.

$ rm -f ~/.irbrc
$ irb
irb(main):001:0> 1
=> 1
irb(main):002:0> 2
=> 2
irb(main):003:0> 3
=> 3
irb(main):004:0> Readline::HISTORY.to_a
=> ["1", "2", "3", "Readline::HISTORY.to_a"]
irb(main):005:0> exit
$ irb
irb(main):001:0> up arrow nothing...
$ echo 'IRB.conf[:SAVE_HISTORY] = 3' > ~/.irbrc
$ irb
irb(main):001:0> 1
=> 1
irb(main):002:0> 2
=> 2
irb(main):003:0> 3
=> 3
irb(main):004:0> Readline::HISTORY.to_a
=> ["1", "2", "3", "Readline::HISTORY.to_a"]
irb(main):005:0> exit
$ irb
irb(main):001:0> Readline::HISTORY.to_a
=> ["3", "Readline::HISTORY.to_a", "exit", "Readline::HISTORY.to_a"]

Recently invoked 3 lines are restored from history file (~/.irb_history or so).

HTH
=end

#5 [ruby-core:51385] Updated by zzak (Zachary Scott) over 4 years ago

history works in 1.9.3, but look:

1.9.3p362 :003 > IRB.conf[:SAVE_HISTORY]
=> nil
1.9.3p362 :004 > RUBY_DESCRIPTION
=> "ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]"

SAVE_HISTORY is nil, just like in trunk

#6 [ruby-core:51393] Updated by no6v (Nobuhiro IMAI) over 4 years ago

If history works even though IRB.conf[:SAVE_HISTORY] is nil,
this may be done by rvm (~/.rvm/scripts/irbrc.rb) if you use.

#7 [ruby-core:51397] Updated by injekt (Lee Jarvis) over 4 years ago

Nobuhiro,

I think the point is, shouldn't we be setting SAVE_HISTORY by default? If version managers are doing this then it should tell us it should probably be done by default. Are there any reasons why this shouldn't be done?

#8 [ruby-core:51398] Updated by zzak (Zachary Scott) over 4 years ago

no6v (Nobuhiro IMAI) wrote:

If history works even though IRB.conf[:SAVE_HISTORY] is nil,
this may be done by rvm (~/.rvm/scripts/irbrc.rb) if you use.

This is true, I see that rvm includes these defaults for us.

#9 [ruby-core:51404] Updated by keiju (Keiju Ishitsuka) over 4 years ago

injekt (Lee Jarvis) wrote:

Nobuhiro,

I think the point is, shouldn't we be setting SAVE_HISTORY by default? If version managers are doing this then it should tell us it should probably be done by default. Are there any reasons why this shouldn't be done?

This behavior of Irb is modeled on csh or tcsh.
I admit that the Irb's document is not sufficient.

#10 [ruby-core:51405] Updated by zzak (Zachary Scott) over 4 years ago

keiju (Keiju Ishitsuka) wrote:

This behavior of Irb is modeled on csh or tcsh.
I admit that the Irb's document is not sufficient.

That is a low blow Keiju-san :(

I will fix the Irb documentation for these configuration options.

#11 [ruby-core:51407] Updated by no6v (Nobuhiro IMAI) over 4 years ago

BTW, history file is world readable. Is it ok?
.history (t?csh), .histfile (zsh) and .bash_history (bash) can be read by only its owner.

#12 [ruby-core:51425] Updated by keiju (Keiju Ishitsuka) over 4 years ago

no6v (Nobuhiro IMAI) wrote:

BTW, history file is world readable. Is it ok?
.history (t?csh), .histfile (zsh) and .bash_history (bash) can be read by only its owner.

Surely, this is a problem.
Please, create ticket for this bug.

#13 Updated by no6v (Nobuhiro IMAI) over 4 years ago

Surely, this is a problem.
Please, create ticket for this bug.

Submitted as #7694. Thanks in advance.

#14 [ruby-core:51522] Updated by zzak (Zachary Scott) over 4 years ago

  • Status changed from Assigned to Closed

Thank you for the feedback

Also available in: Atom PDF