require upper/lower case filenames on a Windows box...

Discussion in 'Ruby' started by Stephan Kämper, Feb 1, 2005.

  1. Hi,

    I'm running the latest one-click-installer (1.8.2-14) on a WinXP box.

    With

    require 'Date'

    you'll likely get an error, but with

    require 'date'

    you won't...

    [irb session begin] ------------------------------------
    E:\>irb
    irb(main):001:0> require 'Date'
    c:/ruby/lib/ruby/1.8/Date.rb:238: warning: already initialized constant
    MONTHNAMES
    c:/ruby/lib/ruby/1.8/Date.rb:243: warning: already initialized constant
    DAYNAMES
    c:/ruby/lib/ruby/1.8/Date.rb:247: warning: already initialized constant
    ABBR_MONTHNAMES
    c:/ruby/lib/ruby/1.8/Date.rb:250: warning: already initialized constant
    ABBR_DAYNAMES
    c:/ruby/lib/ruby/1.8/Date.rb:254: warning: already initialized constant
    ITALY
    c:/ruby/lib/ruby/1.8/Date.rb:258: warning: already initialized constant
    ENGLAND
    c:/ruby/lib/ruby/1.8/Date.rb:262: warning: already initialized constant
    JULIAN
    c:/ruby/lib/ruby/1.8/Date.rb:266: warning: already initialized constant
    GREGORIAN
    NameError: undefined method `today' for `DateTime'
    from c:/ruby/lib/ruby/1.8/Date.rb:1261:in `undef_method'
    from c:/ruby/lib/ruby/1.8/Date.rb:1261
    from
    c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require__'
    from
    c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require'
    from (irb):1
    [irb session end] ------------------------------------




    This doesn't seem to be an irb issue since running "require 'date'"
    outside irb yields the same result:

    E:\>ruby -v
    ruby 1.8.2 (2004-12-25) [i386-mswin32]

    E:\>ruby -r Date -e ''
    c:/ruby/lib/ruby/1.8/date.rb:238: warning: already initialized constant
    MONTHNAMES
    ---------------- [snipped part of the output] ----------------



    BTW, on the identical hardware running Linux I get...

    [stk@tao ~]$ ruby -v
    ruby 1.8.2 (2004-12-25) [i686-linux]
    [stk@tao ~]$ ruby -r date -e ''
    [stk@tao ~]$

    ... no error, while 'Date' raises a file not found Error.


    Aha, I think this happens: On Linux everything works fine. :)

    On Windows however, the case dependency with respect to filenames
    is sub-optimal. Requiring the file with the 'correct' file name
    'date' yields the expected behaviour ('require' returns false).

    But requiring a slightly misspelled filename as 'Date' leads to
    the following:

    1. 'Date' is not found in the list of already loaded files.
    2. Loading the file doesn't yield an Error - because Windows
    finds 'date'.
    3. Bad things happen on a Windows box, while processing that file.



    Happy rubying

    Stephan
    Stephan Kämper, Feb 1, 2005
    #1
    1. Advertising

  2. Stephan Kämper wrote:
    > Hi,
    >
    > I'm running the latest one-click-installer (1.8.2-14) on a WinXP box.
    >
    > With
    >
    > require 'Date'
    >
    > you'll likely get an error, but with
    >
    > require 'date'


    "Date" != "date", even on Win32. Plus, NTFS supports case sensitive
    file names.
    The error is not exactly what I would expect, though.

    Dan
    Daniel Berger, Feb 1, 2005
    #2
    1. Advertising

  3. On Wed, 2 Feb 2005 01:25:44 +0900, Daniel Berger
    <> wrote:
    > Stephan Kämper wrote:
    >> I'm running the latest one-click-installer (1.8.2-14) on a WinXP
    >> box.
    >>
    >> With
    >> require 'Date'
    >> you'll likely get an error, but with
    >> require 'date'

    > "Date" != "date", even on Win32. Plus, NTFS supports case
    > sensitive file names. The error is not exactly what I would
    > expect, though.


    Mmmm. Case preserving, not case sensitive. One of the things that MS
    and Apple got right and Unix got wrong.

    -austin
    --
    Austin Ziegler *
    * Alternate:
    Austin Ziegler, Feb 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    699
    Jürgen Exner
    Dec 7, 2004
  2. B.J.
    Replies:
    4
    Views:
    732
    Toby Inkster
    Apr 23, 2005
  3. Janice

    lower case to upper case

    Janice, Dec 10, 2004, in forum: C Programming
    Replies:
    17
    Views:
    1,156
    Richard Bos
    Dec 14, 2004
  4. penny
    Replies:
    28
    Views:
    2,349
    Charlton Wilbur
    Mar 10, 2008
  5. BlackHelicopter
    Replies:
    0
    Views:
    499
    BlackHelicopter
    Jan 31, 2013
Loading...

Share This Page