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.
Activity
Vladimir Sizikov
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Summary | File.open("C:/foo/bar", "wb") throws IOError instead of Errno::ENOENT | File.open raises IOError instead of Errno::ENOENT |
| Affects Version/s | JRuby 1.4 [ 15285 ] | |
| Component/s | Core Classes/Modules [ 12230 ] | |
| Assignee | Thomas E Enebo [ enebo ] | Vladimir Sizikov [ vvs ] |
| Fix Version/s | JRuby 1.5 [ 15792 ] |
Vladimir Sizikov
made changes -
| 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. |
Ruby 1.8.x has the following behavior: {noformat} 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 {noformat} JRuby instead gives the following: {noformat} 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 {noformat} 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): {code} 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 {code} I'll write a spec and apply a patch soon. |
Michael Johann
made changes -
| Attachment | JRUBY-4380.patch [ 46558 ] |
Vladimir Sizikov
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Charles Oliver Nutter
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
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.