Hello,
As per the documentation (https://www.lua.org/pil/8.1.html), global variable LUA_PATH should have precedence against environmental variable, it it seems it hasn't :
My env is :
$ echo $LUA_PATH
./?.lua;/usr/lib/lua/luarocks/share/lua/5.1/?.lua;/usr/lib/lua/luarocks/share/lua/5.1/?/init.lua;/usr/lib/lua/5.1/?.lua;/usr/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua
and my code is the following :
---
LUA_PATH = MARCEL_SCRIPT_DIR ..'/?.lua;' .. os.getenv('LUA_PATH')
print(_G['LUA_PATH'])
require ( "Photovoltaics" )
---
Where MARCEL_SCRIPT_DIR is another variable pointing to another directory for my application.
But at runtime, LUA_PATH is correctly set
---
/mnt/sata/trv/Projets/Marcel/scripts/?.lua;./?.lua;/usr/lib/lua/luarocks/share/lua/5.1/?.lua;/usr/lib/lua/luarocks/share/lua/5.1/?/init.lua;/usr/lib/lua/5.1/?.lua;/usr/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua
---
but require() is failling :
---
*F* 'scripts/AllScripts.lua' : scripts/AllScripts.lua:13: module 'Photovoltaics' not found:
no field package.preload['Photovoltaics']
no file './Photovoltaics.lua'
no file '/usr/lib/lua/luarocks/share/lua/5.1/Photovoltaics.lua'
no file '/usr/lib/lua/luarocks/share/lua/5.1/Photovoltaics/init.lua'
no file '/usr/lib/lua/5.1/Photovoltaics.lua'
no file '/usr/lib/lua/5.1/Photovoltaics/init.lua'
no file '/usr/share/lua/5.1/Photovoltaics.lua'
no file '/usr/share/lua/5.1/Photovoltaics/init.lua'
no file './Photovoltaics.so'
no file '/usr/lib/lua/luarocks/lib/lua/5.1/Photovoltaics.so'
no file '/usr/lib/lua/luarocks/lib/lua/5.1/loadall.so'
---
so it looks to me the environmental variable is still used and my global LUA_PATH ignored ?
Is my code wrong or is it a bug ?
Thanks
Laurent