質問

〜/ .irbrcに私はこれらの行を持っています

require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"

と私はirbを実行し、打つときはまだ矢印何も起こりません。また、指定されたIRB履歴ファイルが作成され、何もそこに記録されません取得されていません。

役に立ちましたか?

解決

上記が動作しない理由を私はあなたのための答えを持っていないが、私は私のシステム上のファイル、/etc/irbrc見つけた - 、持続的な作業を提供しません(OS XのSnow Leopard、Rubyの1.8.7を)私の履歴。だから、アドバイスの2枚は:ⅰ)あなたの設定に干渉する可能性がそこに何がないことを確認するためには/ etc / irbrc(または同等品)をチェックし、及びii)あなたが得ることができるかどうかを確認するために以下の設定を試してみます歴史にそのように働いています。

# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks

unless defined? ETC_IRBRC_LOADED

  # Require RubyGems by default.
  require 'rubygems'

  # Activate auto-completion.
  require 'irb/completion'

  # Use the simple prompt if possible.
  IRB.conf[:PROMPT_MODE] = :SIMPLE if IRB.conf[:PROMPT_MODE] == :DEFAULT

  # Setup permanent history.
  HISTFILE = "~/.irb_history"
  MAXHISTSIZE = 100
  begin
    histfile = File::expand_path(HISTFILE)
    if File::exists?(histfile)
      lines = IO::readlines(histfile).collect { |line| line.chomp }
      puts "Read #{lines.nitems} saved history commands from '#{histfile}'." if $VERBOSE
      Readline::HISTORY.push(*lines)
    else
      puts "History file '#{histfile}' was empty or non-existant." if $VERBOSE
    end
    Kernel::at_exit do
      lines = Readline::HISTORY.to_a.reverse.uniq.reverse
      lines = lines[-MAXHISTSIZE, MAXHISTSIZE] if lines.nitems > MAXHISTSIZE
      puts "Saving #{lines.length} history lines to '#{histfile}'." if $VERBOSE
      File::open(histfile, File::WRONLY|File::CREAT|File::TRUNC) { |io| io.puts lines.join("\n") }
    end
  rescue => e
    puts "Error when configuring permanent history: #{e}" if $VERBOSE
  end

  ETC_IRBRC_LOADED=true
end

他のヒント

irbの歴史は、箱から出してのDebian Linux上で動作します。そこにはなど/ irbrcはません、また私は〜/ .irbrcを持っています。だから、うーむます。

この人はより彼のirbrcでもう少し入れをあなたがやりました。あなたはARGV.concatが欠けているかもしれないと思いますか。

require 'irb/completion'
require 'irb/ext/save-history'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" 

これは、利用可能なパッチと既知のバグです。最も簡単な解決策は、セーブ・history.rbを上書きすることです。

/usr/lib/ruby/1.8/irb/ext/save-history.rb

固定バージョンでます:

http://pastie.org/513500する

あるいは一度にそれを行うには:

wget -O /usr/lib/ruby/1.8/irb/ext/save-history.rb http://pastie.org/pastes/513500/download
IRB歴史はそれなしで動作しないようだと、

あなたがlibreadlineとルビーを建てたことを確認してください。

あなたは余分なIRBの設定ファイルを持っている場合は、

これはまた、例えば、発生する可能性があり~/.irbrc。このような場合は、追加の設定にliwpの回答からコンテンツをコピーして、それが動作するはずです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top