lua-users home
lua-l archive

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


Followup: Couldn’t make it work with “.” as given (“./?.lua”).
 
I had to change it to “/progs/lua/?.lua” which means I have to hardcode the apps directory, which I don’t particularly like.  “./?.lua” seems to do the same as the default “.” search.
 
Many thanks, though.  It’s still a ‘partial’ solution.
 
From: Coroutines
Sent: Saturday, April 05, 2014 11:20 PM
Subject: Re: Suggestion for Lua 5.3.0 -- require search paths
 
If you want to add a new search directory for require you would do so for .lua files with package.path, with package.cpath for .so or .dll files (shared libraries that export a luaopen_*() function).
 
I frequently do this in a project if I'm requiring in a .lua from the same directory:
 
package.path = './.lua;' .. package.path
 
require 'local_file'
 
Look at package.path, it search those directories for the file you're require'ing in from left-to-right -- all the directories are between ; (; is the separator)
 
Remember: package.path for .lua -- package.cpath for .so/.dll


On Sat, Apr 5, 2014 at 1:11 PM, <tonyp@acm.org> wrote:
Correction:
app.lua starts with “require ‘app_lib’”