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

  • Thread starter Stephan Kämper
  • Start date
S

Stephan Kämper

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
 
D

Daniel Berger

Stephan said:
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
 
A

Austin Ziegler

"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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top