lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Oct 5, 2011 at 7:36 PM, Rob Hoelz <> wrote:
> "How do I tell require to search relative to the current module?"

It's a good question, because it illuminates the central role of package.path.

The solution I use is to look at _G.arg[0] and work out the base path
from that; this seems to work fine and is the basis for
app.require_here() in Penlight:  Then we modify package.(c)path

(If anybody _could_ see a potential problem with this method I would
be grateful)

I've seen people use debug information of the main script to find this
out, but I can't see any advantages of this.  It would not work if
debug information had been stripped, for instance.

steve d.