JRuby

Dir['...'] incompatibilities between Ruby and accross platforms

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 0.9.0, JRuby 0.9.1, JRuby 0.9.2, JRuby 0.9.8, JRuby 0.9.9, JRuby 1.0.0RC1, JRuby 1.0.0RC2
  • Fix Version/s: JRuby 1.0.0RC3
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Number of attachments :
    0

Description

I opened this up as a continuation of JRUBY-31, since the core problem reported in that bug is fixed and this bug has another dimension not captured in the comments in that bug. So as a general description, Dir[] does not return the exact strings that Ruby would. On top of that between windows and linux we do not return the same string either.
Here are the known incompatibilities:

Dir['./abc'] => ['abc'] # On windows, this is correct in linux ([./abc])
Dir[.] => [/Users/mcovarru/Documents/workspace] # On windows, linux is ??? ([.] correct)

The risk of these incompatibilities is small if they are using Dir[] for file manipulation since it represents the same file logically. It is large if they expect the string for some specific string manipulation.

Activity

Hide
Charles Oliver Nutter added a comment -

This represents an incompatiblity, so we should try to fix it for 1.0...but since it involves symlinks, it may not be possible. Do what we can, or punt on it and give a good reason why we can't do it. And update the wiki to let people know

Show
Charles Oliver Nutter added a comment - This represents an incompatiblity, so we should try to fix it for 1.0...but since it involves symlinks, it may not be possible. Do what we can, or punt on it and give a good reason why we can't do it. And update the wiki to let people know
Hide
Charles Oliver Nutter added a comment -

Punting to post-RC2. In danger of falling out of 1.0.

Show
Charles Oliver Nutter added a comment - Punting to post-RC2. In danger of falling out of 1.0.
Hide
Daniel Berger added a comment -

I can't duplicate this on Windows XP Pro, with either 1.8.5 or 1.8.6:

C:\TEST>irb
irb(main):001:0> Dir['foo']
=> ["foo"]
irb(main):002:0> Dir['./foo']
=> ["./foo"]
Show
Daniel Berger added a comment - I can't duplicate this on Windows XP Pro, with either 1.8.5 or 1.8.6:
C:\TEST>irb
irb(main):001:0> Dir['foo']
=> ["foo"]
irb(main):002:0> Dir['./foo']
=> ["./foo"]
Hide
Daniel Berger added a comment -

Further research indicates that the SetCurrentDirectory() function from kernel32 behaves the same way, i.e. understands "/" to mean root of the current path.

Show
Daniel Berger added a comment - Further research indicates that the SetCurrentDirectory() function from kernel32 behaves the same way, i.e. understands "/" to mean root of the current path.
Hide
Thomas E Enebo added a comment -

From testing by windows users it appears original tests are now working....resolving. If someone knows of another Dir[] problem, then please open up a new issue.

Show
Thomas E Enebo added a comment - From testing by windows users it appears original tests are now working....resolving. If someone knows of another Dir[] problem, then please open up a new issue.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: