# Rake + FileUtils == warining

**URL:** <https://www.ruby-forum.com/t/rake-fileutils-warining/113281>\
**Category:** Ruby\
**Created:** [August 29, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281 "2007-08-29T14:59:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 29, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/1 "2007-08-29T14:59:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 29, 2007, 3:03pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/2 "2007-08-29T15:03:37Z")

</div>

Ronald F. wrote:

> constant S\_IF\_DOOR  
> 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…

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 29, 2007, 3:22pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/3 "2007-08-29T15:22:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 29, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/4 "2007-08-29T23:56:38Z")

</div>

Ronald F. wrote:

> > > constant OPT\_TABLE  
> > > 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.

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 29, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/5 "2007-08-29T21:12:47Z")

</div>

Ronald F. wrote:

> > > constant OPT\_TABLE  
> > > when I also started to use rake. It seems that Ruby had at least  
> > > included _something_ when I asked for FileUtils…
> 
> –  
> Ronald F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Phone: +49-89-452133-162

The file to be required is /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.

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [August 31, 2007, 9:24am UTC](https://www.ruby-forum.com/t/rake-fileutils-warining/113281/6 "2007-08-31T09:24:43Z")

</div>

> sensitive.  
> You are right! I’m pretty sure that was it!

Thanks for the clarification.

Ronald
