Dir fails if path does not exist instead of returning nil #2291
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:
@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...
referenced this issue
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.