1

This seems to be a Ruby 1.9 problem for me, but anytime I try to require or autoload source with something like require "lib/mylibrary" Ruby fails with a "No such file to load" error. I always have to interpolate Dir.pwd thusly: require "#{Dir.pwd}/lib/mylibrary"

I see source everywhere that doesn't need to look up the present working directory to include source files. What am I missing?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
cmhobbs
  • 2,469
  • 3
  • 24
  • 30

1 Answers1

5

The $LOAD_PATH variable determines the places that Ruby will check for files to load. As of Ruby 1.9, the current directory is not in the load path by default, but you can use the require_relative method to require files relative to the current working directory.

See this question for more details.

Community
  • 1
  • 1
Tim Destan
  • 2,028
  • 12
  • 16