Hi,
I’ve set my .irbrc file with those line :
require ‘irb/ext/save-history’
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = “#{ENV[‘HOME’]}/.irb-save-history”
but my commands are not saved to .irb-save-history after exiting irb.
my entire .irbrc file can be found here : http://pastie.org/512760
I’ve dived a bit inside the save-history code and it seems that the
HistorySavingAbility.create_finalizer proc is never called.
The finalizer is set for the main_context @io object : an
IRB::ReadlineInputMethod object
I’ve googled a lot about irb history but all I could find was the irbrc
setup repeated again and again.
Has anyone had this kind of issue before ?
ruby -v # => ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9]
++
Ju
Julien P. wrote:
require ‘irb/ext/save-history’
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = “#{ENV[‘HOME’]}/.irb-save-history”
Fwiw, my .irbrc is missing that last line, but it does work, and saves
history to ~/.irb_history . Maybe there is a problem with explicitly
setting the history file?
Thx for your answer Joel, but I’ve tried with and without the line with
no success …
Joel VanderWerf wrote:
Julien P. wrote:
require ‘irb/ext/save-history’
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = “#{ENV[‘HOME’]}/.irb-save-history”
Fwiw, my .irbrc is missing that last line, but it does work, and saves
history to ~/.irb_history . Maybe there is a problem with explicitly
setting the history file?
Julien P. wrote:
Thx for your answer Joel, but I’ve tried with and without the line with
no success …
I had the same problem. IRB uses (for whatever obscure reason)
finalizers to do the saving. Now finalizers are not guaranteed to be
run. And that’s exactly what happens.
I wrote a fix for my save-history.rb, but I’m not sure how clean it is.
Anyway, for now it solves my problem and I’ll share it with you. Hope it
helps you too:
http://pastie.org/513500
I put it into /opt/local/lib/ruby/site_ruby/1.8/irb/ext/save-history.rb,
you may have to change the /opt/local/lib part to where your ruby’s lib
path is.
Regards
Stefan R.
Julien P. wrote:
Hi Stefan,
Looks like this is a know bug, and you can find the ticket here
http://redmine.ruby-lang.org/issues/show/1556
The ticket was opened on June 2nd, but the bug appeared in the repo at
1.8.7-p83 (unreleased version), which is 5 month old. Hope it will be
fixed in the next release.
In the mean time, you can easily fix it yourself with the simple 2 lines
patch detailed at the end of the ticket.
Regards
Julien
Ah, good to know that they know. Sadly, I don’t speak japanese so I
wouldn’t find that entry.
However, my patch does almost exactly what the patch there does
(replaces the finalizer with an at_exit hook), but additionally adds the
ability to save only unique lines, via the IRB.conf[:HISTORY_NO_DUPS]
config option.
Regards
Stefan
Stefan R. wrote:
Julien P. wrote:
Thx for your answer Joel, but I’ve tried with and without the line with
no success …
I had the same problem. IRB uses (for whatever obscure reason)
finalizers to do the saving. Now finalizers are not guaranteed to be
run. And that’s exactly what happens.
I wrote a fix for my save-history.rb, but I’m not sure how clean it is.
Anyway, for now it solves my problem and I’ll share it with you. Hope it
helps you too:
http://pastie.org/513500
I put it into /opt/local/lib/ruby/site_ruby/1.8/irb/ext/save-history.rb,
you may have to change the /opt/local/lib part to where your ruby’s lib
path is.
Regards
Stefan R.
Hi Stefan,
Looks like this is a know bug, and you can find the ticket here
http://redmine.ruby-lang.org/issues/show/1556
The ticket was opened on June 2nd, but the bug appeared in the repo at
1.8.7-p83 (unreleased version), which is 5 month old. Hope it will be
fixed in the next release.
In the mean time, you can easily fix it yourself with the simple 2 lines
patch detailed at the end of the ticket.
Regards
Julien