irb-historyを導入したらエラー発生

公開日: : Ruby

記事内に広告を含む場合があります。記事内で紹介する商品を購入することで、当サイトに売り上げの一部が還元されることがあります。

irb-historyのインストールは以下のようにしました。


# sudo gem install irb-history

インストールされたバージョンについてはこんな感じ。


Macintosh% gem list --local | grep history
irb-history (1.0.0)
Persistent, shared IRB Readline history

irb-history-serberは以下のようにして起動しました。


# irb-history-server -d

.irbrcに以下の記述を追加


require 'rubygems'
require 'irb/history'
IRB::History.start_client

irbを実行してみると、以下のようなエラーが発生。


irb(main):001:0> 123
/Library/Ruby/Gems/1.8/gems/irb-history-1.0.0/lib/irb/history/client.rb:23:in `[]': invalid index (IndexError)
from /Library/Ruby/Gems/1.8/gems/irb-history-1.0.0/lib/irb/history/client.rb:23:in `gets'
from /Library/Ruby/Gems/1.8/gems/irb-history-1.0.0/lib/irb/history/base.rb:23:in `returning'
from /Library/Ruby/Gems/1.8/gems/irb-history-1.0.0/lib/irb/history/client.rb:22:in `gets'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:132:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:259:in `signal_status'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:131:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/ruby-lex.rb:189:in `call'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/ruby-lex.rb:189:in `buf_input'
... 11 levels...
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:70:in `start'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `start'
from /usr/bin/irb:13
Macintosh%

client.rbを覗いてみる。


1 require File.join(File.dirname(__FILE__), 'base')
2
3 module IRB #:nodoc:
4 module History
5 # Reconfigures a running IRB session to use the given remote history
6 # service specified by +uri+, initially retrieving +lines_to_recall+
7 # lines of history.
8 #
9 # Note: This method overrides +gets+ in IRB::ReadlineInputMethod; it
10 # can't be "stopped," and you shouldn't call it more than once.
11 #
12 def self.start_client(uri = DEFAULT_URI, lines_to_recall = 100)
13 require 'drb'
14
15 DRb.start_service
16 history = DRbObject.new nil, uri
17
18 IRB::ReadlineInputMethod.instance_eval do
19 alias_method :old_gets, :gets
20
21 define_method :gets do
22 returning old_gets do
23 line = Readline::HISTORY[-1]
24 history.remember line unless @eof rescue nil
25 end
26 end
27 end
28
29 Readline::HISTORY.push *history.recall(lines_to_recall)
30
31 at_exit {history.unsubscribe_from Readline::HISTORY} if
32 history.subscribe_to Readline::HISTORY
33 rescue
34 end
35 end
36 end%

うーん、何でだろう?

関連記事

サンフランシスコのピア39にあるチャウダーズでクラムチャウダーを食す!

lolipop アップルの開発者向けイベント「WWDC2014」

ミスドのカルピスドーナツとカルピスポンデリングを食べてみた!

ミスドで期間限定のカルピスコラボ商品「カルピスドーナツ」と「カルピ

十三カレー計画で牛すじカレーネギのせを食す!(大阪・十三)

「iPhoneアプリ開発キャンプ@大阪」のランチで、十三カレー計画

大阪・難波の加寿屋 法善寺でかすうどんを食す。ランチタイムはおにぎり2個まで無料!

大阪・難波の加寿屋 法善寺 (かすうどん KASUYA)で、かす

ライブドアブログで運営していた「あきお商店」を「卵は世界である」に改名しました

少し前からライブドアブログで「あきお商店」というブログをやって

→もっと見る

PAGE TOP ↑