Project

General

Profile

Actions

Bug #6455

closed

IRB.conf[:RC_NAME_GENERATOR] と IRB.conf[:SAVE_HISTORY] を同時に設定すると irb が起動できないのを修正する

Added by sho-h (Sho Hashimoto) almost 12 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
Backport:
[ruby-dev:45654]

Description

るりまを書いている最中に気づいたのですが、IRB.conf[:RC_NAME_GENERATOR] と IRB.conf[:SAVE_HISTORY] を同時に設定すると irb の起動時にヒストリファイルの読み込みで例外が発生して irb が起動できません。

$ irb
/usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in exist?': can't convert nil into String (TypeError) from /usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in load_history'
...
$

IRB.rc_file("_history") が nil を返すようになるためではないかと思います。

$ irb -f
irb(main):001:0> IRB.conf[:RC_NAME_GENERATOR] = Proc.new { |rc|
irb(main):002:1* ["/tmp/myirb.#{rc}"].detect { |path| File.exists?(path) }
irb(main):003:1> }
irb(main):004:0> IRB.rc_file("_history")
=> nil

1.8.7 で試しましたが、trunk でも同様ではないかと思います。

lib/irb/ext/save-history.rb で IRB.rc_file("_history") が nil であればデフォルト値を使うなどされた方がいいかもしれません。

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Status changed from Open to Assigned

Updated by keiju (Keiju Ishitsuka) about 11 years ago

sho-h (Sho Hashimoto) wrote:

$ irb
/usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in exist?': can't convert nil into String (TypeError) from /usr/lib/ruby/1.8/irb/ext/save-history.rb:77:in load_history'

IRB.rc_file("_history") が nil を返すようになるためではないかと思います。

この件ですが、RC_NAME_GENARATOR を間違って定義している(正しいファイル名を生成しないでnilを返す)ために発生しています。
文字列を返さなければ、例外を発生することにしました。

Actions #3

Updated by keiju (Keiju Ishitsuka) about 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38600.
Sho, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/irb/init.rb, lib/irb/lc/ja/error.rb, lib/irb/lc/error.rb:
    raise exception when illegal RC_NAME_GENARATOR defined [Bug #6455].
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0