Alex Young
8/29/2007 9:56:00 PM
Ronald Fischer wrote:
>> Ronald Fischer wrote:
>>> When I require both rake and FileUtils, i.e.
>>>
>>> require 'rake' # for String#ext
>>> require 'FileUtils'
>>>
>>> I get the following warnings:
>>>
>>> c:/ruby186/lib/ruby/1.8/FileUtils.rb:93: warning: already
>> initialized
>>> constant OPT_TABLE
>
> [snip]
>
>> Are you sure you don't want to require 'fileutils' rather than
>> 'FileUtils'?
>
> Indeed, I needed to write it as 'fileutils' and the error disappears.
>
> Now I wonder why I never got an error before in my application
> (I had always required 'FileUtils' before, but got an error only
> when I also started to use rake. It seems that Ruby had at least
> included *something* when I asked for FileUtils.....
>
I think what's happening here is a conflict between Ruby's require
mechanism being case sensitive, and Windows' pathnames not being case
sensitive. When you say 'require "fileutils"', Ruby remembers that it
has seen something called "fileutils" so that it can avoid loading the
same file twice. When you then 'require "FileUtils"' later, Ruby
doesn't think it has seen it before, because it's in a different case,
so it queries the filesystem. Because Windows doesn't distinguish
between upper and lower case, it returns the same file as before, which
Ruby then tries to reload. The errors are thus from the same file being
loaded twice, but via two different names that resolve to the same file.
--
Alex