Skip to content
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.executable? raises an exception if the `file_path` is non-existent and native disabled #2297

Closed
rtyler opened this Issue Dec 10, 2014 · 6 comments

Comments

Projects
None yet
3 participants
@rtyler
Copy link

rtyler commented Dec 10, 2014

jruby-1.7.15 :001 > File.executable? '/tmp/not-a-thing'
File.executable? '/tmp/not-a-thing'
 => false 
jruby-1.7.15 :002 > 
1.9.3-p484 :001 > File.executable? '/tmp/not-a-thing'
 => false 
1.9.3-p484 :002 > 

And of course, on JRuby 1.7.17:

jruby-1.7.17 :001 > File.executable? '/tmp/not-a-thing'
Errno::ENOENT: No such file or directory - /tmp/not-a-thing
    from org/jruby/RubyFileTest.java:100:in `executable?'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1107:in `eval'
    from org/jruby/RubyKernel.java:1507:in `loop'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from org/jruby/RubyKernel.java:1270:in `catch'
    from /home/tyler/.rvm/rubies/jruby-1.7.17/bin/irb:13:in `(root)'
jruby-1.7.17 :002 > 

@rtyler rtyler added the JRuby 1.7.x label Dec 10, 2014

@rtyler rtyler added this to the JRuby 1.7.18 milestone Dec 10, 2014

@rtyler

This comment has been minimized.

Copy link
Author

rtyler commented Dec 10, 2014

This causes this #which function in bundler to raise an exception insead of properly installing the gems :(

@rtyler

This comment has been minimized.

Copy link
Author

rtyler commented Dec 10, 2014

It looks like this doesn't reproduce on Mac OS X or Linux, but does on FreeBSD :(

ubuntu@ip-10-83-13-213:~/lookout-rack-utils$ irb
jruby-1.7.17 :001 > File.executable? '/tmp/not-a-thing'
 => false 
jruby-1.7.17 :002 > 
ubuntu@ip-10-83-13-213:~/lookout-rack-utils$ uname -a
Linux ip-10-83-13-213 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ip-10-83-13-213:~/lookout-rack-utils$ 
``
@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Dec 10, 2014

that is the same thing we had with file?, dir? and readable? - they all
failed the same way when native was disabled (or could not be loaded).

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Dec 10, 2014

just read the thread again. this also means on FreeBSD the JFFI native lib
fails to load.

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Dec 10, 2014

Repro on MacOS or anywhere (tip o the hat to mkristian):

./bin/jruby -Xnative.enabled=false -e 'File.executable?("/tmp/notathing")'
Errno::ENOENT: No such file or directory - /tmp/notathing
  executable? at org/jruby/RubyFileTest.java:100
       (root) at -e:1

@enebo enebo changed the title File.executable? raises an exception if the `file_path` is non-existent File.executable? raises an exception if the `file_path` is non-existent and native disabled Dec 10, 2014

mkristian added a commit that referenced this issue Dec 10, 2014

fix File.executable? when native is disabled
use the new canExecute method from the FileResource to answer the question.
for File#executable_real? use posix if native is available. also added
tests for executable? as well for executable_real?. fixes #2297

Sponsored by Lookout Inc.
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Dec 10, 2014

Fixed in jnr-posix. LibcHelper was throwing ENOENT on failure (which is used by pure-Java impl). It should return -1 and let the higher level one do it.

@enebo enebo closed this Dec 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.