Skip to content

Commit

Permalink
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kernel/common/code_loader.rb
Original file line number Diff line number Diff line change
@@ -137,10 +137,14 @@ def require
# check to make sure it's not called inside of an eval.
def self.require_relative(name, scope)
script = scope.current_script
if script && script.data_path.nil?
raise LoadError.new "cannot infer basepath from #{script.file_path}"
elsif script
require File.expand_path(name, File.dirname(File.realdirpath(script.data_path)))
if script
if script.data_path
path = File.dirname(File.realdirpath(script.data_path))
else
path = Dir.pwd
end

require File.expand_path(name, path)
else
raise LoadError.new "Something is wrong in trying to get relative path"
end

0 comments on commit 6dfb925

Please sign in to comment.