# Unloading (or unrequiring) a file

**URL:** <https://www.ruby-forum.com/t/unloading-or-unrequiring-a-file/112371>\
**Category:** Ruby\
**Created:** [August 18, 2007, 12:59am UTC](https://www.ruby-forum.com/t/unloading-or-unrequiring-a-file/112371 "2007-08-18T00:59:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ari\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Ari\_B](https://www.ruby-forum.com/u/Ari_B)\
**Post date:** [August 18, 2007, 12:59am UTC](https://www.ruby-forum.com/t/unloading-or-unrequiring-a-file/112371/1 "2007-08-18T00:59:55Z")

</div>

Hey all,

I’m trying to dynamically load parts of code to make things and  
methods available.

The catch is that I’d also like to make those things and methods  
UNavailable as well (or load something else in place of the original  
loaded item).

I know there’s no Kernel#unload, so how can I achieve my goal?

Thanks,  
aRi  
-------------------------------------------|  
Nietzsche is my copilot

---

<div class="post-metadata">

**Author:** ![Ari\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Ari\_B](https://www.ruby-forum.com/u/Ari_B)\
**Post date:** [August 18, 2007, 1:15am UTC](https://www.ruby-forum.com/t/unloading-or-unrequiring-a-file/112371/2 "2007-08-18T01:15:57Z")

</div>

On 8/17/07, Ari B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

As far as methods go there’s remove\_method and undef\_method. For  
constants theres remove\_const. An idea I’ve had was to fork, although  
that’s a little heavy handed

eg:

… code …  
pid = fork do  
require ‘this\_will\_go\_away’  
but\_so\_will\_this\_var = ThisWillGoAway.new  
but\_so\_will\_this\_var.do\_something  
end

Process.wait pid

p but\_so\_will\_this\_var # NameError
