Skip to content

Instantly share code, notes, and snippets.

@maxim
Created December 5, 2012 01:43
Show Gist options
  • Select an option

  • Save maxim/4211278 to your computer and use it in GitHub Desktop.

Select an option

Save maxim/4211278 to your computer and use it in GitHub Desktop.
Why tempfiles disappear randomly
>> GC.disable
=> false
>>
>> def foo
>> file = Tempfile.new('test')
>> file.path
>> end
=> nil
>>
>> path = foo
=> "/var/folders/m4/04vc0n6j51xc9c1vwx3nq1480000gn/T/test20121204-84071-k6epzk"
>>
>> File.exists?(path)
=> true
>>
>> GC.enable
=> true
>>
>> GC.start
=> nil
>>
>> File.exists?(path)
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment