Bug #7679
closedIRB history is broken
Added by zzak (zzak _) almost 12 years ago. Updated almost 12 years ago.
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]
Updated by zzak (zzak _) almost 12 years ago
- Status changed from Open to Assigned
Updated by injekt (Lee Jarvis) almost 12 years ago
I also tried with the following:
bin/irb -rirb/ext/save-history
But with the same outcome.
Updated by injekt (Lee Jarvis) almost 12 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]"
Updated by no6v (Nobuhiro IMAI) almost 12 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
Updated by zzak (zzak _) almost 12 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
Updated by no6v (Nobuhiro IMAI) almost 12 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.
Updated by injekt (Lee Jarvis) almost 12 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?
Updated by zzak (zzak _) almost 12 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.
Updated by keiju (Keiju Ishitsuka) almost 12 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.
Updated by zzak (zzak _) almost 12 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.
Updated by no6v (Nobuhiro IMAI) almost 12 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.
Updated by keiju (Keiju Ishitsuka) almost 12 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.
Updated by no6v (Nobuhiro IMAI) almost 12 years ago
Surely, this is a problem.
Please, create ticket for this bug.
Submitted as #7694. Thanks in advance.
Updated by zzak (zzak _) almost 12 years ago
- Status changed from Assigned to Closed
Thank you for the feedback