Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
warning: Tempfile#unlink or delete called on open file; ignoring #1752
From https://jira.codehaus.org/browse/JRUBY-6688 and further to http://markmail.org/search/?q=list%3Aorg.codehaus.jruby.user#query:list%3Aorg.codehaus.jruby.user+page:1+mid:l5s47zvynzk7ki3a+state:results jruby unlike mri emits a warning when unlinking an open temp file.
Per http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html this should be acceptable behaviour.
@stan3 per http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html it is only acceptable on POSIX systems. Because the JVM abstracts away such OS-specific features, JRuby is (in my opinion) correct to always emit this warning, since it actually cannot unlink the file. In my opinion, MRI should also be emitting such a warning on Windows, where this is not possible.
In my opinion the only acceptable solution would be to actually unlink the file (possibly via spawn or JNI if not otherwise possible) on POSIX systems and not emit this warning in that case. Although I do not know if JVM has any problems reading/writing a file that no longer exists.
EDIT: However to be fair the Tempfile docs say
referenced this issue
Sep 29, 2014
Long ago I tried to stat() on a Tempfile I had called #unlink on with JRuby. (For background, on CRuby this works on both POSIX and Windows as CRuby has the file descriptor or has not unlinked the file, respectively.) For JRuby this failed as the stat system call used required the filename on JRuby (lstat). It could not use the file descriptor call (fstat) as the JVM did not provide access to it.
In order to fix this bug, on JRuby, Tempfile was changed to never unlink the file. Since this matched behavior on Windows it seemed like the least intrusive fix. At the same time the warning was added as the JRuby behavior differed from CRuby behavior.
I asked @headius about this on twitter, here is his reply: