lua-users home
lua-l archive

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

It was thus said that the Great Daurnimator once stated:
> On 4 February 2017 at 20:23, Sean Conner <> wrote:
> >   Where do you add the "application path"?  Do you prepend it to
> > package.path?  Or append it to package.path?
> You don't want to modify package.path for this type of functionality.
> A key note is that the string you pass to the `require` function is
> what the module is saved under in `package.loaded`.
> It *has* to be something a function that wraps or re-implements
> `require` itself.
> Now I ask: why are we taking about this in relation to file systems?
> package searchers can be abstract, and don't have to be bound by a
> file system layout.
> I think the only reasonable way to accomplish a 'relative require' is
> to use the *current* module path as a prefix.

  The question wasn't loading modules relative to other modules, but
relative to a non-module script.  The example was:

	   app.lua	-- require "module"

If you are in foo/, then "lua app.lua" works.  But it fails if you aren't in
foo---"lua foo/app.lua".  What you are talking about is subtly different,
but probably related.