# "Unrequire" a file?

**URL:** <https://www.ruby-forum.com/t/unrequire-a-file/58968>\
**Category:** Ruby\
**Created:** [April 27, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/unrequire-a-file/58968 "2006-04-27T14:31:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@tuka](https://www.ruby-forum.com/u/tuka)\
**Post date:** [April 27, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/unrequire-a-file/58968/1 "2006-04-27T14:31:17Z")

</div>

Hi,

after making changes to a particular file,  
I would either like to overwrite the already included one or ‘unrequire’  
the existing one. Is this possible ?

My tests below indicate it is not…

TIA,  
Tuka

C:\Ruby\hotelreg\>ruby script/console  
Loading development environment.

> > require ‘db/migrate/001\_tb\_hotel.rb’  
> > =\> true
> 
> > TbHotel.down  
> > == TbHotel: reverting  
> > =========================================================  
> > – drop\_table(:hotels)  
> > -\> 0.2900s  
> > == TbHotel: reverted (0.3000s)  
> > ================================================

=\> nil

> > TbHotel.up  
> > == TbHotel: migrating  
> > =========================================================  
> > – create\_table(:hotels)  
> > -\> 0.1000s  
> > == TbHotel: migrated (0.1000s)  
> > ================================================

=\> nil

> > require ‘db/migrate/001\_tb\_hotel.rb’  
> > =\> false
> 
> >

---

<div class="post-metadata">

**Author:** ![tuka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@tuka](https://www.ruby-forum.com/u/tuka)\
**Post date:** [April 27, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/unrequire-a-file/58968/2 "2006-04-27T14:40:26Z")

</div>

On 4/27/06, Tuka O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> after making changes to a particular file,  
> I would either like to overwrite the already included one or ‘unrequire’  
> the existing one. Is this possible ?

ri Kernel#load

-austin

---

<div class="post-metadata">

**Author:** ![tuka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@tuka](https://www.ruby-forum.com/u/tuka)\
**Post date:** [April 27, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/unrequire-a-file/58968/3 "2006-04-27T14:53:24Z")

</div>

Hi,

> > after making changes to a particular file,  
> > I would either like to overwrite the already included one or ‘unrequire’  
> > the existing one. Is this possible ?  
> > ri Kernel#load

Well, you could also remove the file from the array $", and rerequire  
it, but I would not recommend it ;).  
($" contains the list of the files loaded with ‘require’ and is used  
to check that a file is not loaded twice)

Cheers,  
Vincent ISAMBART

---

<div class="post-metadata">

**Author:** ![tuka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7c8e57/32.png) [@tuka](https://www.ruby-forum.com/u/tuka)\
**Post date:** [April 27, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/unrequire-a-file/58968/4 "2006-04-27T18:15:26Z")

</div>

many thanks for your input.

Worked great  
Tuka
