Why is LUA_EXEC_DIR Windows only?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Why is LUA_EXEC_DIR Windows only?

Scott Morgan
In Windows the package.path and .cpath fields accept LUA_EXEC_DIR '!' as
the location of the executable running Lua, but in the Linux builds this
isn't the case. (see: luaconf.h, loadlib.c)

Why the different behaviours between platforms?

Scott

Reply | Threaded
Open this post in threaded view
|

Re: Why is LUA_EXEC_DIR Windows only?

steve donovan
On Fri, Jun 5, 2015 at 2:33 PM, Scott Morgan <[hidden email]> wrote:
> Why the different behaviours between platforms?

The short answer is that it's surprisingly tricky to get the
executable's actual location on the filesystem on non-Windows systems;
argv[0] is not your friend.  A common tactic is to customize a
sandboxed Lua by modifying luaconf.h (e.g. luabuild)

Reply | Threaded
Open this post in threaded view
|

Re: Why is LUA_EXEC_DIR Windows only?

Peter Drahoš
In reply to this post by Scott Morgan

> On 5.6.2015, at 14:33, Scott Morgan <[hidden email]> wrote:
>
> In Windows the package.path and .cpath fields accept LUA_EXEC_DIR '!' as
> the location of the executable running Lua, but in the Linux builds this
> isn't the case. (see: luaconf.h, loadlib.c)
>
> Why the different behaviours between platforms?
>
> Scott
>
In LuaDist this feature[1] is supported on most other platforms as it is essential for locating modules installed alongside the executable. As you can see from the code it is VERY platform specific and in few cases unreliable.

This is the only modification applied to Lua in the LuaDist distribution.

pd

[1] https://github.com/LuaDist/lua/blob/master/src/loadlib_rel.c#L144

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Why is LUA_EXEC_DIR Windows only?

Scott Morgan
On 05/06/15 17:39, Peter Drahoš wrote:
> In LuaDist this feature is supported on most other platforms as it
> is essential for locating modules installed alongside the
> executable. As you can see from the code it is VERY platform
> specific and in few cases unreliable.
>
> This is the only modification applied to Lua in the LuaDist
> distribution.


I had a feeling it'd need something like this. Thanks for the example.

I think I'll manage with a wrapper script to set the path environment
vars for now (probably the most Unixy way) and let the Windows EXEs
look after themselves.

Scott