History not saving

半腔热情 提交于 2019-12-22 00:28:54

问题


Why is my irb history no longer saving?


回答1:


It turns out that ruby 1.8.7 introduced a bug whereby finalizers are no longer guaranteed to run.

To resolve this, I added the following code snippet to my .irbrc file:

require 'irb/ext/save-history'

Kernel.at_exit do
  IRB::HistorySavingAbility.create_finalizer.call(IRB.CurrentContext.instance_variable_get(:@io).send(:binding))
end



回答2:


I ran into this with ruby 2.3.7 as well. It was caused by rvm ruby package not having the correct permissions to update the default .irbrc_history file. This appears to be a known bug.

An easy work around is to just change the location of this history file in your ~/.irbrc file.

IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"


来源:https://stackoverflow.com/questions/1752461/history-not-saving

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!