Bug #7679

IRB history is broken

Added by Zachary Scott over 1 year ago. Updated about 1 year ago.

[ruby-core:51347]
Status:Closed
Priority:Normal
Assignee:Keiju Ishitsuka
Category:lib
Target version:2.0.0
ruby -v:2.0.0 Backport:

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 Zachary Scott about 1 year ago

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

History

#1 Updated by Zachary Scott over 1 year ago

  • Status changed from Open to Assigned

#2 Updated by Lee Jarvis over 1 year ago

I also tried with the following:

bin/irb -rirb/ext/save-history

But with the same outcome.

#3 Updated by Lee Jarvis over 1 year 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> RUBYDESCRIPTION
=> "ruby 1.9.3p327 (2012-11-10 revision 37606) [x86
64-darwin12.2.0]"

#4 Updated by Nobuhiro IMAI over 1 year 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.toa
=> ["1", "2", "3", "Readline::HISTORY.to
a"]
irb(main):005:0> exit
$ irb
irb(main):001:0> up arrow nothing...
$ echo 'IRB.conf[:SAVEHISTORY] = 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.toa"]
irb(main):005:0> exit
$ irb
irb(main):001:0> Readline::HISTORY.to
a
=> ["3", "Readline::HISTORY.toa", "exit", "Readline::HISTORY.toa"]

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

HTH
=end

#5 Updated by Zachary Scott over 1 year ago

history works in 1.9.3, but look:

1.9.3p362 :003 > IRB.conf[:SAVEHISTORY]
=> 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 Updated by Nobuhiro IMAI over 1 year 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 Updated by Lee Jarvis over 1 year 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 Updated by Zachary Scott over 1 year 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 Updated by Keiju Ishitsuka over 1 year 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 Updated by Zachary Scott over 1 year 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 Updated by Nobuhiro IMAI over 1 year 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 Updated by Keiju Ishitsuka over 1 year 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 Nobuhiro IMAI over 1 year ago

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

Submitted as #7694. Thanks in advance.

#14 Updated by Zachary Scott about 1 year ago

  • Status changed from Assigned to Closed

Thank you for the feedback

Also available in: Atom PDF