Skip to content

Commit e573c2d

Browse files
committed
fix(core): Allow LUA_PATH env var to take effect at runtime
1 parent fb60f92 commit e573c2d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/pathsetup.lua.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ if "@LUA_PATH@" ~= "" then
44
package.cpath = "@LUA_CPATH@"
55
end
66

7+
-- In the event the user has exported Lua environment variables, use them like a system Lua VM would. This essentially
8+
-- nukes the existing runtime path and uses only the new value. This is useful for using `eval $(luarocks --local path)`
9+
-- or similar incantations that setup a path that will reach 3rd party modules.
10+
local env_lua_path = os.getenv("LUA_PATH")
11+
if env_lua_path then
12+
package.path = env_lua_path
13+
end
14+
local env_lua_cpath = os.getenv("LUA_CPATH")
15+
if env_lua_cpath then
16+
package.cpath = env_lua_cpath
17+
end
18+
719
local executable = debug.getinfo(3, "S").source
820
local luaversion = _VERSION:match("%d+%.%d+")
921

0 commit comments

Comments
 (0)