Require command

Hello
I am using ruby192 and when ever i use “require” to load another saved
module it doesn’t work how ever “load” works perfectly
Why is that? How can i fix this? and will this affect my code when i
start using gems?
Thanks

On Sep 20, 2011, at 3:14 PM, Aya A. wrote:

Hello
I am using ruby192 and when ever i use “require” to load another saved
module it doesn’t work how ever “load” works perfectly
Why is that? How can i fix this? and will this affect my code when i
start using gems?
Thanks

Well, typically it’s:

require “some_file”

and

load “some_file.rb”

Also, know that require only pulls the file in the first time, while
load will read (and execute) the source file every time.

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

Well I tried that it still doesn’t work here is the error message it
generates:
internal:lib/rubygems/custom_require:29:in require': no such file to load -- account (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire’
from test_libraries.rb:1:in `’

On Tue, Sep 20, 2011 at 9:14 PM, Aya A. [email protected]
wrote:

Hello
I am using ruby192 and when ever i use “require” to load another saved
module it doesn’t work how ever “load” works perfectly
Why is that?

Probably because you are trying to require a file in or from within
(via “my/file/path”) the current working directory (aka ‘.’)

How can i fix this?

require_relative “my_file”
require_relative “my/file/path”

and will this affect my code when i
start using gems?

Gems are in the gem search path of RubyGems, so: No, it won’t.


Phillip G.

gplus.to/phgaw | twitter.com/phgaw

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibniz

require_relative “my_file” Works just fine!!
Thank you Phillip for your help :slight_smile: