[erlang-questions] [RE] Case insensitivity - Windows trap or bug?

Doug Edmunds <>
Sat Jan 19 18:42:53 CET 2008


Hi Alex,

Erlang-under-Cygwin might not be the cure that you think it is:

Go back to my original scenario:
   A file named myTest.erl.
   No file named mytest.erl

You got this result:
 > 2> c(mytest).
 > ** Module name 'myTest' does not match file name 'mytest' **
 > {error,badfile}

c/1 has two phases, first it compiles the erl file (
creating a beam file), then it tries to load the beam file.
The message {error,badfile} is generated during the load phase and 
doesn't reach the issue.  I get the same result using Erlang-under-XP.

The focus of the issue is the compile phase.

If Erlang-under-Cygwin were trapping 'mytest.erl' as a non-
existent file (i.e. in a case sensitive way), it would generate a 
different error message, something like this:

7> c(badspelling).
./badspelling.erl:none: no such file or directory
error

But it didn't generate that error.

Please put myTest.erl in an empty directory, then
using Erlang-under-Cygwin, run c(mytest) with all
small letters.  Now look in the directory.
Did Erlang-under-Cygwin create a beam file?
My guess is that it does AND that it is named mytest.erl.

-- Doug Edmunds


> 
> I can at least tell you that in Windows via Cygwin (pretty much acting 
> like a Unix system) does gives out an error, as it should.
> 
> 1> c(myTest).
> {ok,myTest}
> 2> c(mytest).
> ** Module name 'myTest' does not match file name 'mytest' **
> {error,badfile}
> 
> The behavior you're experiencing is Window SOP.  The deal with Unix or 
> Unix-like systems is that you can have file 'test.erl' and also file 
> 'Test.erl,' but not in Windows, as they would be exactly the same file 
> (even under Cygwin).  Hence, there's no problem!
> 
> Cheers, Alex
> 
> 
> 
>     ---------[ Received Mail Content ]----------
> 
>     *Subject : *[erlang-questions] Case insensitivity - Window! s trap
>     or bug?
> 
>     *Date : *Tue, 15 Jan 2008 13:14:04 -0800
> 
>     *From : *Doug Edmunds <>
> 
>     *To : *
> 
> 
> 
>     The Erlang compiler assumes that filenames are
> 
>     case sensitive. It does not check the existence
> 
>     of a file based on a case-sensitive spelling.
> 
>     But Windows filenames are not case sensitive.
> 
>     This can lead to unexpected results.
> 
> 
> 
>     (I don't have a *nix system to check this on. I
> 
>     assume this is a Windows-only problem.)
> 
> 
> 
>     ------
> 
>     Assume this scenario:
> 
>     (note the spelling, a capital T in both file name and module).
> 
> 
> 
>     a file named: myTest.erl
> 
>     containing a module: -module(myTest).
> 
> 
> 
>      > compile:file(myTest).
> 
>     produces myTest.beam
> 
> 
> 
>     So far so good.
> 
> 
> 
>     ------
> 
> 
> 
>     An inadvertent typo can cause unexpected results
> 
>     which are not flagged b! y the compiler (in Windows):
> 
> 
> 
>     1.
> 
> 
> 
>      > co mpile:file(mytest). %% case insensitive input accepted.
> 
>     {ok,myTest} %% note difference between input and output
> 
> 
> 
>     What is the filename just created?
> 
>     'mytest.beam', not 'myTest.beam'
> 
> 
> 
>     Any errors or warnings? No.
> 
> 
> 
> 
> 
>     ----
> 
> 
> 
>     2. Having done step 1, things can become very strange:
> 
>     Remember, the name of the beam file is mytest.beam.
> 
>     There is no myTest.beam.
> 
> 
> 
>      > code:file_load(myTest).
> 
>     {module,myTest} %% loads
> 
> 
> 
> 
> 
>     3. But this doesn't work:
> 
> 
> 
>      >code:file_load(mytest).
> 
> 
> 
>     =ERROR REPORT==== 15-Jan-2008::09:56:50 ===
> 
>     beam/beam_load.c(1035): Error loading module mytest:
> 
>     module name in object code is myTest
> 
> 
> 
> 
> 
>     =ERROR REPORT==== 15-Jan-2008::09:56:50 ===
> 
>     Loading of c:/erl_dae2/compile sensitivity bugs/mytest.beam failed:
>     badfile
> 
>     {error,badfile}
> 
> 
> 
>     --------! -
> 
> 
> 
>     Running erlc from a DOS shell, has the same problems.
> 
>     erlc ignores case, and compiles a beam
> 
>     file that does not match the internal module name.
> 
> 
> 
>     erlc mytest.erl %% erlc accepts this filename in Windows
> 
> 
> 
>     produces mytest.beam from myTest.erl without any warning.
> 
>     The mytest.beam will have the same usage issues as indicated
> 
>     above (it will contain a module name 'myTest' and will not load.
> 
> 
> 
>     -------------------
> 
>     I think of these as bugs. Other Erlang functions
> 
>     can capture/retain filename case sensitivity in Windows.
> 
>     (c:ls/0, for example reports myTest.erl). You won't change
> 
>     Windows. The Erlang compiler functions need to test
> 
>     for file existence based on case-sensitivity.
> 
> 
> 
>     Doug Edmunds
> 
> 
> 
> 
> 
>     _______________________________________________
> 
>     erlang-questions mailing list
> 
>     
> 
>     http://www.erl! ang.org/mailman/listinfo/erlang-questions
> 
> < /td>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list