문제

~/.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)에서 나에게 일하고 지속적인 역사를 제공합니다. 따라서 두 가지 조언 : i) /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 History는 Debian Linux에서 상자 밖으로 작동합니다. ETC/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" 

패치를 사용할 수있는 알려진 버그입니다. 가장 쉬운 솔루션은 Save-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으로 Ruby를 만들었는지 확인하십시오.

추가 IRB 구성 파일이있는 경우에도 발생할 수 있습니다. ~/.irbrc. 이 경우 LiWP의 답변에서 추가 구성에 대한 내용을 복사하면 작동해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top