[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Load module/package from string
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 31 Mar 2011 11:53:52 +0200
On Thu, Mar 31, 2011 at 11:41 AM, <firstname.lastname@example.org> wrote:
>> assert (loadfile ('.\\lib\\defs.lua'))
>> dofile ('test.lua')
> test.lua:1: module 'defs' not found:
This is one of those cases where package.path is needed - loadfile()
looks on a filesystem path, but the require() inside test.lua looks on
the Lua module path.
So if you had this line before the dofile():
package.path = [[lib\?.lua;]]..package.path
then things would work, because the _pattern_ lib\?.lua would match
with ? equal to 'def'.