If I have two scripts that reference each other on the same directory
A/
foo.lua
bar.lua
foo.lua
require "bar"
bar.lua
print "It worked"
then running the lua executable from the same folder works
cd A; lua foo.lua
but running the interpreter from another folder fails with a "module 'bar' not found" message
cd A/..; lua A/foo.lua
Is there a way to have my relative imports not depend on the current working directory? For example, in batch files I can setup my paths to be relative to dirname $0
.