5

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!

dualed
10.5k1 gold badge28 silver badges30 bronze badges
asked Feb 21, 2019 at 17:44
0

4 Answers 4

6

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
answered Aug 1, 2022 at 17:32
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This was hardly obvious, but as soon as a -dev Lua installation is added with apt, it automagically updates LUA_INCDIR!
4

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

answered Feb 21, 2019 at 20:30

1 Comment

Hi, thanks for helping me out!, I tried to do a very similair format, but i could not find the lua folder in opt, even though i have lua installed. Now, i have the error: "fatal error: lua.h: No such file or directory"
3

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!

answered Feb 22, 2019 at 16:11

Comments

1

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.

answered Aug 3, 2022 at 6:26

1 Comment

In Ubuntu 22.04, you can use alternatives instead. /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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.