Ruby tempfile instances automatically delete their corresponding file when the references are released. However, I have one machine on which this is not the case. The code is
irb> require 'tempfile'
=> true
irb> t = Tempfile.new('test32')
=> #<File:/tmp/test32.27778.0>
irb> exit
on all of my test machines, this results in test32 getting deleted, except one. I have tried to delete a file using File.delete
and unfortunately that works fine. Is there some ruby config I'm missing?
Ruby version is
ruby 1.8.6 (2009-06-08 patchlevel 369) [i686-linux].
Edit: Some additional information that has come to light in the conversation with DigitalRoss: If I explicitly release the Tempfile reference (t = nil), then the Tempfile gets cleaned up. Is is possible that the GC has been patched or altered in some way to need that?
Here's some code that works on the "good" machines but on the "bad" machine it fails
include ObjectSpace
t = "blah"
define_finalizer(t, proc {|id| print "yes finalized id=#{id}", "\n" })
On the bad machine, the "yes finalized" only prints if I explicitly set t to nil.