# Warning: method redefined

**URL:** <https://www.ruby-forum.com/t/warning-method-redefined/193813>\
**Category:** Ruby\
**Created:** [August 24, 2010, 8:54pm UTC](https://www.ruby-forum.com/t/warning-method-redefined/193813 "2010-08-24T20:54:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tensaiji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/6de8d8/32.png) [@tensaiji](https://www.ruby-forum.com/u/tensaiji)\
**Post date:** [August 24, 2010, 8:54pm UTC](https://www.ruby-forum.com/t/warning-method-redefined/193813/1 "2010-08-24T20:54:32Z")

</div>

Hi,

Any idea how to track down `warning: method redefined` errors? Is there  
a way to force errors to appear with irb when I load individual files?

AFAICS I’ve not redefined anything. It’s all my own, very small library.  
This all started when I installed 1.9.2, which I’m beginning to regret  
for the amount of consternation it’s causing me.

Regards,  
Iain

---

<div class="post-metadata">

**Author:** ![tensaiji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/6de8d8/32.png) [@tensaiji](https://www.ruby-forum.com/u/tensaiji)\
**Post date:** [August 24, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/warning-method-redefined/193813/2 "2010-08-24T21:29:04Z")

</div>

On 24 Aug 2010, at 19:49, Iain B. wrote:

> Hi,
> 
> Any idea how to track down `warning: method redefined` errors? Is there a way to force errors to appear with irb when I load individual files?

It turns out one of the other files in the library also had require  
'file/fo’o etc, so some files were required twice. What I don’t  
understand is why this would generate warnings, as my understanding is  
that require can be called as multiple times but will only load the  
files once. Is this incorrect?

Regards,  
Iain

---

<div class="post-metadata">

**Author:** ![tensaiji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/6de8d8/32.png) [@tensaiji](https://www.ruby-forum.com/u/tensaiji)\
**Post date:** [August 26, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/warning-method-redefined/193813/3 "2010-08-26T15:57:46Z")

</div>

Iain B. wrote:

> It turns out one of the other files in the library also had require  
> 'file/fo’o etc, so some files were required twice. What I don’t  
> understand is why this would generate warnings, as my understanding is  
> that require can be called as multiple times but will only load the  
> files once. Is this incorrect?

It can happen if you require them in different ways, e.g.

require ‘file/fo’  
require ‘./file/fo’  
require ‘…/lib/file/fo’  
require File.join(File.dirname( **FILE** ), ‘fo’)

If that’s what’s happening, the solution is to be consistent with your  
require statements, and if necessary set up $: (aka $LOAD\_PATH) suitably  
at the start of your program.

---

<div class="post-metadata">

**Author:** ![tensaiji](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/6de8d8/32.png) [@tensaiji](https://www.ruby-forum.com/u/tensaiji)\
**Post date:** [August 26, 2010, 4:47pm UTC](https://www.ruby-forum.com/t/warning-method-redefined/193813/4 "2010-08-26T16:47:16Z")

</div>

On 26 Aug 2010, at 14:57, Brian C. wrote:

> require ‘./file/fo’  
> require ‘…/lib/file/fo’  
> require File.join(File.dirname( **FILE** ), ‘fo’)
> 
> ## If that’s what’s happening, the solution is to be consistent with your require statements, and if necessary set up $: (aka $LOAD\_PATH) suitably at the start of your program.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Ah, I see. Yes, a part of the code was dynamically calling require, and  
the offending statements were static.

One more gotcha in the bag! Thanks. Nice thing about all the “gotchas”  
I’ve found in Ruby so far is that they may be frustrating at the time,  
but they don’t kill the fun of the language.

Regards,  
Iain
