I am running ubuntu and installed luarocks, however, whenever I try to install a something like luasocket (luarocks install luasocket), it throws me the following error:
Error: Failed finding Lua library. You may need to configure LUA_LIBDIR
Both my config files look like this:
rocks_trees = {
{ name = "user", root = home .. "/.luarocks" };
{ name = "system", root = "/usr/local" };
}
lua_interpreter = "lua5.3";
variables = {
LUA_DIR = "/usr/include/lua53";
LUA_BINDIR = "/usr/bin/lua53";
}
Any help is appreciated!
4 Answers 4
I had this same issue in Ubuntu 22.04, lua 5.3, luarocks 3.8, arm64. In my system the /usr/local/opt directory doesn't exist, so the top answer here didn't help.
In my case, the LUA_INCDIR needed to point at /usr/include/lua5.3, but the default lua installation (apt install lua5.3) doesn't create the necessary file and directories.
Installing liblua5.3-dev solved the problem. It creates the needed file and directories in the correct locations.
apt install liblua5.3-dev
1 Comment
-dev Lua installation is added with apt, it automagically updates LUA_INCDIR!You need to add LUA_LIBDIR to the variable it should look something like this:
rocks_trees = { "/usr/local/lib/luarocks/5.1" }
variables = {
LUA = "/usr/local/opt/lua/bin/lua5.1",
LUA_BINDIR = "/usr/local/opt/lua/bin",
LUA_INCDIR = "/usr/local/opt/lua/include",
LUA_LIBDIR = "/usr/local/opt/lua/lib",
}
Resources for config file:
http://lua-users.org/wiki/LuaRocksConfig
https://github.com/luarocks/luarocks/wiki/Config-file-format
1 Comment
thanks for the responses, however i got it working by:
uninstalling lua uninstalling luarocks
installing lua5.1 as well as the development version installing luarocks as instructed on luarocks.org
the problem for me was i somehow got lua5.3 as my main lua version, but somehow had other version source files, so i just had to completely delete everything and make sure i download consistent versions. Hope this helps anyone else!
Comments
I faced this issue in Ubuntu 22.04 arm64. The solution for me was to go /usr/bin and remove lua then rename lua5.4 to lua.
1 Comment
/usr/bin/lua is a symlink to /etc/alternatives/lua-interpreter which in turn points to the correct interpreter for the current Lua version you wish to use as default (e.g. /usr/bin/lua5.4 if you wish). See the manual page for update-alternatives and run `update-alternatives --query lua-interpreter´ to see what alternatives are available for the Lua interpreter.