Skip to content

Commit ca6452f

Browse files
committed
lua*: support relative modules even when there are system modules
previously, when the lua setup hook found a system lua module, it would simply add that library to LUA_PATH, meaning the default path would no longer be used. for luajit, this bug would always occur, due to it having several inbuilt libraries such as luabitop. lua5 still passed unit tests, simply because the test environment doesn't include any system lua libaries, but the bug would still occur if lua5 was used in a derivation with a buildInput from luaPackages, since that package would be found by the envHook and overwrite the default path. now, the setup hook will use any system module paths in addition to the default path, instead of overriding it.
1 parent 1b0e18a commit ca6452f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkgs/development/interpreters/lua-5/hooks/setup-hook.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ addToLuaSearchPathWithCustomDelimiter() {
2222
# export only if we haven't already got this dir in the search path
2323
if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
2424

25+
# if the path variable has not yet been set, initialize it to ";;"
26+
# this is a magic value that will be replaced by the default,
27+
# allowing relative modules to be used even when there are system modules.
28+
if [[ -v "${varName}" ]]; then export "${varName}=;;"; fi
29+
2530
export "${varName}=${!varName:+${!varName};}${absPattern}"
2631
}
2732

0 commit comments

Comments
 (0)