You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a script that require("socket.unix") and the library is installed in Ubuntu with apt install lua-socket.
But the OpenResty can't resolve the library:
no file '/usr/local/lib/lua/5.1/socket.so'
This is because it's not it the /usr/local/lib/lua/ but in /usr/lib/x86_64-linux-gnu/lua/.
But this will work if a library was installed with luarocks because it's indeed uses the /usr/local/lib/lua/.
I tried to solve this by adding lua_package_path and lua_package_cpath like this:
# By default Lua libraies are looked in the /usr/local/share/lua/ and /usr/local/lib/lua/ but must look into /usr/share/lua/ and /usr/lib/x86_64-linux-gnu/lua/
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/usr/share/lua/5.1/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;;';
This partially solved a problem but failed with another error attempt to call method 'get_certificate' (a nil value).
This is probably because packages has own directories that also needs to be added recursively.
I had to add them manually like this:
# By default Lua libraies are looked in the /usr/local/share/lua/ and /usr/local/lib/lua/ but must look into /usr/share/lua/ and /usr/lib/x86_64-linux-gnu/lua/
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/socket/?.lua;/usr/share/lua/5.1/ssl/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/socket/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/mime/?.so;;';
This again didn't worked, don't know why. Anyway this solution would be fragile. Once a new library with own folder installed it also should be manually added to the path.
The only solution that worked was to create symlinks:
This is not something that I like but solves the problem for now.
I wish to hear how to solve this correctly. At least please add more examples to the lua_package_path and lua_package_cpath.
The text was updated successfully, but these errors were encountered:
yurtpage
changed the title
LUA_PATH must contain /usr/share/lua and
LUA_PATH must contain /usr/share/lua and /usr/lib/x86_64-linux-gnu/lua/
Apr 10, 2024
I have a script that
require("socket.unix")
and the library is installed in Ubuntu withapt install lua-socket
.But the OpenResty can't resolve the library:
This is because it's not it the
/usr/local/lib/lua/
but in/usr/lib/x86_64-linux-gnu/lua/
.But this will work if a library was installed with luarocks because it's indeed uses the
/usr/local/lib/lua/
.I tried to solve this by adding
lua_package_path
andlua_package_cpath
like this:This partially solved a problem but failed with another error
attempt to call method 'get_certificate' (a nil value)
.This is probably because packages has own directories that also needs to be added recursively.
I had to add them manually like this:
This again didn't worked, don't know why. Anyway this solution would be fragile. Once a new library with own folder installed it also should be manually added to the path.
The only solution that worked was to create symlinks:
This is not something that I like but solves the problem for now.
I wish to hear how to solve this correctly. At least please add more examples to the
lua_package_path
andlua_package_cpath
.The text was updated successfully, but these errors were encountered: