0

Edited for clarity

From

puts $LOAD_PATH 

I am able to see my load paths. I do

$LOAD_PATH << 'C:/rubyfiles' 

to add ruby files to my search path. I then put some random custom rb file in there and do

require 'ya' 

LoadError - No such file to load

What am I doing wrong?

5
  • Can you show us the code you're using so far? Commented Apr 18, 2011 at 0:22
  • 1
    Why are you putting your own files directly in that directory? That's not the correct practice. Commented Apr 18, 2011 at 0:22
  • 1
    Then tell me the correct practice. Simply, where do I put my custom rb file and add to search path to require. Commented Apr 18, 2011 at 0:25
  • For a single one-off script, for a web project (e.g. Rails, Sinatra, or other) or are you creating utility code that you want available for many scripts? Commented Apr 18, 2011 at 1:15
  • Just messing around with the basics in the irb Commented Apr 18, 2011 at 3:09

4 Answers 4

1

Try doing

puts "$LOAD_PATH is #{$LOAD_PATH.inspect}" puts "Files in rubyfiles is #{Dir.entries('C:/rubyfiles').inspect}" 

and add the output of that debugging to the question.

Sign up to request clarification or add additional context in comments.

Comments

0

When you want to load the file name with xxx.rb, you have load xxx.rb, not load xxx. This is one difference from require. Are you clear with that?

1 Comment

A good point, but given the presence of require in the question, this seems unlikely to be the issue.
0

Guess I trusted too much in someone elses code which had an error. Still somewhat new with ruby thus I mistook the loaderror for issues with the main file without bothering to look in the code itself. Thanks anyways.

1 Comment

Don't forget to accept this so that the question's treated as answered.
0

You can put your custom .rb files in lib/ folder inside your rails project

p/s: assuming it's a rails project

1 Comment

Oh my mistake, thought this was tagged under rails too

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.