[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

irb save-history not working

Julien Palmas

6/15/2009 7:44:00 PM

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....

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
--
Posted via http://www.ruby-....

5 Answers

Joel VanderWerf

6/15/2009 7:55:00 PM

0

Julien Palmas 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?

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Julien Palmas

6/15/2009 8:13:00 PM

0

Thx for your answer Joel, but I've tried with and without the line with
no success ...

Joel VanderWerf wrote:
> Julien Palmas 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?
--
Posted via http://www.ruby-....

Stefan Rusterholz

6/16/2009 7:57:00 AM

0

Julien Palmas 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....

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 Rusterholz
--
Posted via http://www.ruby-....

Julien Palmas

6/16/2009 9:17:00 AM

0

Stefan Rusterholz wrote:
> Julien Palmas 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....
>
> 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 Rusterholz

Hi Stefan,

Looks like this is a know bug, and you can find the ticket here
http://redmine.ruby-lang.org/issues...

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
--
Posted via http://www.ruby-....

Stefan Rusterholz

6/16/2009 3:00:00 PM

0

Julien Palmas wrote:

> Hi Stefan,
>
> Looks like this is a know bug, and you can find the ticket here
> http://redmine.ruby-lang.org/issues...
>
> 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
--
Posted via http://www.ruby-....