lua-users home
lua-l archive

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


Tomas wrote:

	I'm solving this problem with a LUA_PATH like:


LUA_PATH=/usr/local/lua/?;/usr/local/lua/?.lua;/usr/local/lua/?/?.lua;./?;./?.lua

This works, but makes at least three assumptions:

- All of your Lua modules are installed in the same common folder
- You know in advance the name of that common folder, and have it set up
somewhere (e.g. in an environment variable LUA_PATH)
- All module folders are named as the main modules inside them

I'd prefer to make tools which are intended to run on (almost) any
machine, and do not make so many assumptions. A tool should be installed
by simply unzipping it into a single (unknown in advance) folder, and
then should be able to find all of its dependencies (either internal or
external) when started from within any folder. Well, I admit that
external dependencies (other modules which may be installed anywhere)
cannot be found without having LUA_PATH set to point to them.

Wim Couwenberg wrote:

My "Import" technical note (LTN 11) provides a possible solution:

Yes, this resolves the case for modules which get loaded by require.
However, each "top" module (which can be called from the command line)
should be able to find a common import.lua module, which implements LTN
11, plus the splitFileName function which retrieves the startup
folder. Adding import and something like getStartupPath() (or
getPath(arg[0]) ) to the standard library seems like a good idea...

Regards,
Ivan