rake + FileUtils == warining

R

Ronald Fischer

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

require 'rake'
require 'SomeOtherModule'

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

Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 
A

Alex Young

Ronald said:
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...
 
R

Ronald Fischer

Ronald said:
When I require both rake and FileUtils, i.e.
=20
require 'rake' # for String#ext
require 'FileUtils'
=20
I get the following warnings:
=20
c:/ruby186/lib/ruby/1.8/FileUtils.rb:93: warning: already=20 initialized
constant OPT_TABLE
[snip]

Are you sure you don't want to require 'fileutils' rather than=20
'FileUtils'? =20

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

--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 
A

Alex Young

Ronald said:
Ronald said:
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.
 
R

Ronald Fischer

Indeed, I needed to write it as 'fileutils' and the error=20
disappears.
I think what's happening here is a conflict between Ruby's require=20
mechanism being case sensitive, and Windows' pathnames not being case=20
sensitive.

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

Thanks for the clarification.

Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top