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

Dir[] fails if path does not exist instead of returning nil #2291

Closed
djberg96 opened this issue Dec 9, 2014 · 6 comments
Closed

Dir[] fails if path does not exist instead of returning nil #2291

djberg96 opened this issue Dec 9, 2014 · 6 comments

Comments

@djberg96
Copy link
Contributor

djberg96 commented Dec 9, 2014

jruby 1.7.16 (1.9.3p392) 2014-09-25 575b395 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_07-b10 +jit [Windows 7-amd64]

MRI returns nil if you pass a non-existant path to Dir[]. However, JRuby gets quite upset:

irb(main):001:0> Dir["/foo/bar/baz/jruby.{com,exe,bat,cmd,vbs,vbe,js,jse,wsf,wsh,msc,rb,rbw}"]
Java::JavaLang::IllegalArgumentException: Neither current working directory (null) nor pathname (/foo/bar/baz/jruby.com) led to an absolute path
    from org.jruby.util.JRubyFile.createNoUnicodeConversion(JRubyFile.java:115)
    ...
@enebo enebo added this to the JRuby 1.7.18 milestone Dec 9, 2014
@enebo
Copy link
Member

enebo commented Dec 9, 2014

@djberg96 You missed the window by a few days and I can confirm this is broken on windows only. In doing a quick look I think this must have been broken for a long time/forever? We pass a null cwd in part of the globbing logic and I think that is part of the problem (although I am not positive that is the root cause).

I targeted for next point release since you should not see such basic errors like this in JRuby anymore...

@djberg96
Copy link
Contributor Author

djberg96 commented Dec 9, 2014

Thanks for the update enebo. I'm not sure how long it's been broken. I smoked it out when running the test suite for the ptools library. I -thought- I had done that before with JRuby and it worked, but I guess not.

@enebo
Copy link
Member

enebo commented Dec 9, 2014

It is possible it worked at some point but the explicit null for cwd made me think not.

@headius
Copy link
Member

headius commented Dec 10, 2014

Perhaps only on Windows?

On OS X:

irb(main):001:0> Dir["/foo/bar/baz/jruby.{com,exe,bat,cmd,vbs,vbe,js,jse,wsf,wsh,msc,rb,rbw}"]
=> []

@enebo enebo added the windows label Dec 10, 2014
@enebo
Copy link
Member

enebo commented Dec 10, 2014

yeah only on windows...I should have marked it as such. I figured @djberg96 filing the issue was the same thing though :)

@enebo
Copy link
Member

enebo commented Dec 18, 2014

So I fixed this by putting in a special check that if the absolute file glob path check is "/" try and use Windows system drive letter as the CWD (if system drive is not specified in env I fall back to good ole C:). I opened up #2335 so that we can make sure this works for more than glob. What is weird is I went back to the beginning of 1.7.x (well very close to beginning) and things like File.exist?(C:/opt) return false on jruby but true on MRI. I could have swore this worked at some point. Dir[] does return the same results as MRI when using patterns starting with just /. So I am fixing this one regression with the hopes we can improve windows compat in 1.7.19.

@enebo enebo closed this as completed Dec 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants