Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.4
-
Fix Version/s: JRuby 1.5
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Windows/MacOS/Linux
-
Number of attachments :
Description
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.
Yes, this is JRuby incompatibility. Will fix.
Michael, when you say "write a spec and apply a patch soon", what do you mean? A rubyspec for this particular case, right? And the patch, you mean for JRuby or for radiant?
I have a preliminary patch for this issue as well, but it would be really good to have the specs/tests for that.