-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning: Tempfile#unlink or delete called on open file; ignoring #1752
Comments
This can cause confusion by users, see: |
@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 |
@headius any idea why JRuby emits this warning even though the Ruby docs say it will be silently ignored? Even though it might be useful it is a deviation from MRI and specs. |
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: |
I like @headius' suggestion of making it a verbose mode warning! This warning can be really annoying when it's intended behavior. |
yes that would be cool, @headius seems like a one-liner change right? |
I will make the warning verbose for 1.7.17. For 9k it will usually actually unlink the file and do real fstat against file descriptors, so it's moot when native support is available. |
@headius awesome! Really appreciate all this work you are putting in. |
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.
The text was updated successfully, but these errors were encountered: