Rake + FileUtils == warining

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
c:/ruby186/lib/ruby/1.8/FileUtils.rb:1163: warning: already initialized
constant S_IF_DOOR
c:/ruby186/lib/ruby/1.8/FileUtils.rb:1513: warning: already initialized
constant METHODS

Who is to blame? FileUtils, rake, or me (because I'm not supposed to
require both)?

What can I do to avoid the warnings? Please do not suggest simply
omitting FileUtils
when I'm using rake (I guess the warning results from rake also
including FileUtils).
I don't require them *directly* in the same module. Instead I have

require 'rake'
require 'SomeOtherModule'

in one file, and SomeOtherModule.rb happens to use FileUtils, and this
causes the
warnings in the end.

Ronald

···

--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

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
c:/ruby186/lib/ruby/1.8/FileUtils.rb:1163: warning: already initialized
constant S_IF_DOOR
c:/ruby186/lib/ruby/1.8/FileUtils.rb:1513: warning: already initialized
constant METHODS

Who is to blame? FileUtils, rake, or me (because I'm not supposed to
require both)?

What can I do to avoid the warnings? Please do not suggest simply
omitting FileUtils
when I'm using rake (I guess the warning results from rake also
including FileUtils).
I don't require them *directly* in the same module. Instead I have

require 'rake'
require 'SomeOtherModule'

in one file, and SomeOtherModule.rb happens to use FileUtils, and this
causes the
warnings in the end.

Ronald

Are you sure you don't want to require 'fileutils' rather than 'FileUtils'? The latter gives me errors while the former does not. Actually, it looks to me like rake (or possibly rubygems) requires fileutils anyway...

···

--
Alex

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.....

···

--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

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.....

--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

The file to be required is <install prefix>/lib/ruby/1.8/fileutils.rb which
implements the module FileUtils.

require 'filetuils' => correct, embeds fileutils.rb into current file
include FileUtils => correct, mixes in methods from FileUtils module into
current class/module.

At least, thats how I learned it.... I'm no Ruby professional so don't quote me.

TerryP.

···

--
    
Email and shopping with the feelgood factor!
55% of income to good causes. http://www.ippimail.com

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

> 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.

You are right! I'm pretty sure that was it!

Thanks for the clarification.

Ronald

···

--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162