-
-
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
File.utime failing with JRuby 9.1.16.0 #5075
Comments
Hmm...seems to work ok on master. I'll poke around. |
Ok, I've confirmed this is also working on JRuby 9.1 HEAD (9.1.17.0) so I'm goin gto need more information here.
Can you try running with Also can you confirm what version of OS X you are running on? |
And I'm on OSX 10.12.6 |
And as I was saying, if I switch back to 9.1.15, things work again 😕
|
So the main thing that changed around this logic is that we're now using platform-specific functions to get the nanosecond granularity we want for filesystem times. This works properly on my OS X 10.13 machine, and it should work fine on your 10.12 machine. I'll poke around a bit. It's odd that it can't find this function on your machine. |
Can you try adding flag |
Oops...apparently this function is new in High Sierra: https://bugs.python.org/issue31601 |
The following patch probably fixes this, but it's not ideal (it continues trying to use the missing function): diff --git a/core/src/main/java/org/jruby/RubyFile.java b/core/src/main/java/org/jruby/RubyFile.java
index 94b9e73879..fafb9245c3 100644
--- a/core/src/main/java/org/jruby/RubyFile.java
+++ b/core/src/main/java/org/jruby/RubyFile.java
@@ -42,6 +42,7 @@ import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
+import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.*;
import org.jruby.runtime.JavaSites.FileSites;
import org.jruby.runtime.builtin.IRubyObject;
@@ -1186,7 +1187,19 @@ public class RubyFile extends RubyIO implements EncodingCapable {
throw runtime.newErrnoENOENTError(filename.toString());
}
- int result = runtime.getPosix().utimensat(0, fileToTouch.getAbsolutePath(), atimespec, mtimespec, 0);
+ int result;
+
+ try {
+ result = runtime.getPosix().utimensat(0, fileToTouch.getAbsolutePath(), atimespec, mtimespec, 0);
+ } catch (RaiseException re) {
+ if (re.getException().getMetaClass() == runtime.getNotImplementedError()) {
+ // fall back on utimes
+ result = runtime.getPosix().utimes(fileToTouch.getAbsolutePath(), atimespec, mtimespec);
+ } else {
+ throw re;
+ }
+ }
+
if (result == -1) {
throw runtime.newErrnoFromInt(runtime.getPosix().errno());
} |
@enebo Do you still have an OS X 10.12 machine you could test this on? |
@bastien Here's your first workaround: update to High Sierra! The only other workaround would be to reimplement (monkey patch) We should have a fix for this shortly. |
Patch works |
So we have confirmed this and we have an "ok" patch. Remaining questions:
I will commit the patch for now. |
Nice work. I'll have a look at the patched version next week. |
Environment
Expected Behavior
With jruby-9.1.15.0
Actual Behavior
With jruby-9.1.16.0
The text was updated successfully, but these errors were encountered: