[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rake + FileUtils == warining

Ronald Fischer

8/29/2007 12:58:00 PM

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

4 Answers

Alex Young

8/29/2007 1:02:00 PM

0

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

8/29/2007 1:22:00 PM

0

> 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


Alex Young

8/29/2007 9:56:00 PM

0

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

Ronald Fischer

8/31/2007 7:24:00 AM

0

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