Skip to content

JRuby raises ENOENT instead of EACCES #5617

@joshcooper

Description

@joshcooper

Environment

$ jruby -v
jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 25.162-b12 on 1.8.0_162-b12 +jit [darwin-x86_64]
$ uname -a
Darwin XXX 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64

Expected Behavior

JRuby should raise Errno::EACCES when trying to delete a file whose parent directory is unreadable by the current process, like MRI ruby does:

require 'tmpdir'
Dir.mktmpdir do |dir|
  path = File.join(dir, 'unwritable')
  begin
    File.chmod(0, dir)
    File.unlink(path)
  rescue Errno::ENOENT, Errno::EACCES => e
    puts "raised #{e.class}"
  ensure
    File.chmod(0700, dir)
  end
end
$ rbenv shell 2.5.3
$ ruby --version
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
$ ruby dir.rb
raised Errno::EACCES

Actual Behavior

JRuby raises Errno::ENOENT instead, which is misleading:

$ rbenv shell jruby-9.2.5.0
$ ruby --version
jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 25.162-b12 on 1.8.0_162-b12 +jit [darwin-x86_64]
$ ruby dir.rb
raised Errno::ENOENT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions