File.exist? mystery

Hi there,

The following seems very odd to me (file doesn’t exist after I created
it!). Is there something I did wrong?

irb(main):056:0*’/tmp/test.txt’, ‘w’) { |f| f.write(‘hello’)
=> 5
irb(main):057:0> File.exist?(’/tmp/test.txt’)
=> true
irb(main):058:0> File.expand_path(’/tmp/test.txt’)
=> “D:/tmp/test.txt”
irb(main):059:0> File.exist?(‘D:/tmp/test.txt’)
=> false
irb(main):060:0> File.exist?(‘D:\tmp\test.txt’)
=> false

I am using WindowsXP, and
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java
HotSpot™ Client VM 1.6.0_16) [x86-java]



I think this is a JRuby bug. Take a look:

Basically, JRuby treats ‘/’ at the beginning of the file name a bit
differently than MRI. JRuby treats it as relative path, to the current
directory. MRI treats it as absolute path (to the current drive).


On Thu, Dec 10, 2009 at 1:50 PM, Zemian D. [email protected]

irb(main):058:0> File.expand_path(‘/tmp/test.txt’)

To unsubscribe from this list, please visit: