File.open("C:/foo/bar", "wb") throws IOError instead of Errno::ENOENT
---------------------------------------------------------------------

                 Key: JRUBY-4380
                 URL: http://jira.codehaus.org/browse/JRUBY-4380
             Project: JRuby
          Issue Type: Bug
         Environment: Windows/MacOS/Linux
            Reporter: Michael Johann
            Assignee: Thomas E Enebo


Ruby 1.8.x has the following behavior:

irb(main):006:0> File.open("c:/bla/foo", "wb")
Errno::ENOENT: No such file or directory - c:/bla/foo
        from (irb):6:in `initialize'
        from (irb):6:in `open'
        from (irb):6

JRuby instead gives the following:

irb(main):001:0> File.open("c:/bla/foo", "wb")
IOError: Das System kann den angegebenen Pfad nicht finden
        from (irb):2:in `initialize'
        from (irb):2:in `open'
        from (irb):2

The problem is that IOError is thrown in JRuby while Errno::ENOENT in Ruby MRI.

I found this problem while using Radiant 0.8.1 which has rack-cache on board.
Rack-Cache rescues only Errno::ENOENT and therefore fails to run Radiant.
Here is the code for rack-cache 
(GEM_HOME\gems\radiant-0.8.1\vendor\rack-cache\lib\rack\cache\metastore.rb):

      def write(key, entries)
        path = key_path(key)
        File.open(path, 'wb') do |io|
          Marshal.dump(entries, io, -1) 
        end
      rescue Errno::ENOENT
        Dir.mkdir(File.dirname(path), 0755)
        retry
      end 

I'll write a spec and apply a patch soon.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to