Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4f6edc9753cb^
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da420c9a5235
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on May 13, 2018

  1. Copy the full SHA
    4f6edc9 View commit details
  2. Raise EXDEV when attempting to rename across devices.

    This fix is needed because Bundler now vendors an MRI version of
    fileutils that does not include our hacks for the incorrect EACCES
    error. That is a larger issue since there's other hacks we have
    not eliminated, but this fixes a primary issue bundling libraries.
    headius committed May 13, 2018
    Copy the full SHA
    44bd17d View commit details
  3. Copy the full SHA
    da420c9 View commit details
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3814,6 +3814,10 @@ public RaiseException newErrnoEMSGSIZEError() {
return newRaiseException(getErrno().getClass("EMSGSIZE"), null);
}

public RaiseException newErrnoEXDEVError(String message) {
return newRaiseException(getErrno().getClass("EXDEV"), message);
}

public RaiseException newIndexError(String message) {
return newRaiseException(getIndexError(), message);
}
14 changes: 14 additions & 0 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
@@ -1083,6 +1084,19 @@ public static IRubyObject rename(ThreadContext context, IRubyObject recv, IRubyO
newFile.delete();
}

// Check if source file and dest parent are on same filesystem or raise EXDEV
Path oldPath = Paths.get(oldFile.toURI());
Path destPath = Paths.get(dest.getAbsolutePath());
try {
FileStore oldStore = Files.getFileStore(oldPath);
FileStore destStore = Files.getFileStore(destPath.getParent());
if (!oldStore.equals(destStore)) {
throw runtime.newErrnoEXDEVError("(" + oldFile + ", " + dest + ")");
}
} catch (IOException ioe) {
throw Helpers.newIOErrorFromException(runtime, ioe);
}

if (oldFile.renameTo(dest)) { // try to rename one more time
return RubyFixnum.zero(runtime);
}
Original file line number Diff line number Diff line change
@@ -402,7 +402,7 @@ protected static String printBacktraceJRuby(RubyException exception, boolean con
String message;
try {
message = exception.callMethod(context, "message").toString();
} catch (org.jruby.exceptions.Exception _) {
} catch (org.jruby.exceptions.Exception unused) {
message = exception.message(context).toString();
}
if (exception.getMetaClass() == runtime.getRuntimeError() && message.length() == 0) {
11 changes: 1 addition & 10 deletions lib/ruby/stdlib/fileutils.rb
Original file line number Diff line number Diff line change
@@ -469,7 +469,7 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
end
begin
File.rename s, d
rescue *MV_RESCUES
rescue EXDEV
copy_entry s, d, true
if secure
remove_entry_secure s, force
@@ -484,15 +484,6 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
end
module_function :mv

# JRuby raises EACCES because JDK reports errors differently
MV_RESCUES = begin
if RUBY_ENGINE == 'jruby'
[Errno::EXDEV, Errno::EACCES]
else
[Errno::EXDEV]
end
end

alias move mv
module_function :move