# Check if a file is already required?

**URL:** <https://www.ruby-forum.com/t/check-if-a-file-is-already-required/188848>\
**Category:** Ruby\
**Created:** [May 19, 2010, 10:43am UTC](https://www.ruby-forum.com/t/check-if-a-file-is-already-required/188848 "2010-05-19T10:43:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mszatanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mszatanik](https://www.ruby-forum.com/u/mszatanik)\
**Post date:** [May 19, 2010, 10:43am UTC](https://www.ruby-forum.com/t/check-if-a-file-is-already-required/188848/1 "2010-05-19T10:43:45Z")

</div>

hi,

I made a GUI in wxruby to run ruby/watir test cases/test sets. Framework  
has numerous of modules and global variables, which i can’t require on  
the start of the application.

i figured out that i can just ‘load’ files, but there is a problem with  
global variables. i can load most of files, tho i still have problems  
with few others.

my question is can i, and i i can - how do it unerquire files or check  
are they already required.

meanwhile i’ll try to move global variables to other files, which i  
already require.

---

<div class="post-metadata">

**Author:** ![mszatanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mszatanik](https://www.ruby-forum.com/u/mszatanik)\
**Post date:** [May 19, 2010, 1:20pm UTC](https://www.ruby-forum.com/t/check-if-a-file-is-already-required/188848/2 "2010-05-19T13:20:49Z")

</div>

2010/5/19 Maciej S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I made a GUI in wxruby to run ruby/watir test cases/test sets. Framework  
> has numerous of modules and global variables, which i can’t require on  
> the start of the application.

Why?

> i figured out that i can just ‘load’ files, but there is a problem with  
> global variables. i can load most of files, tho i still have problems  
> with few others.

What problems do you have?

> my question is can i, and i i can - how do it unerquire files or check  
> are they already required.

require checks that for you and ensures that a file is loaded only once.

> meanwhile i’ll try to move global variables to other files, which i  
> already require.

I don’t have a clear picture of your problem. Maybe refactoring  
global constants into other files that are required helps?

Kind regards

robert
