Why isn’t the current directory included in $LOAD_PATH? This seems odd. I just keep adding it, but is there some reason I am not seeing that it’s just not automatically included?
Why isn’t the current directory included in $LOAD_PATH? This seems odd. I just keep
Share
$LOAD_PATHincludes current directory in Ruby 1.8.7, but this behavior have been changed in 1.9.2. You can find possible explanations for the reasons behind this decision among answers to this question, but I think basic idea is that.in 1.8.7 stands for directory from which your code is executed and not the one where it is located. And in most cases you don’t want that and.in your$LOAD_PATHis not reliable.Using
require_relativein 1.9.2 might be a good solution if you don’t want to add.manually to your$LOAD_PATHeverywhere. You can see here that what it does is just explicit expanding relative path. One thing to note is that it’s not available in versions prior to 1.9.2 so it’ll make your code incompatible with older rubies.