Lua can’t find the module installed on luarocks on Linux

I installed the luarocks package on Linux Mint, and then installed a few rocks such as sudo luarocks to install the telescope, but when running the script through lua script.lua, the module is required to be found .

Meta: Do this Q&A style, because although there is a question to answer this question, it doesn’t seem to be a usual title or easy to find, I hope I can help this person.

In this particular case, the problem is that in my distribution, the default Lua version installed is writing At 5.2, the LuaRocks package was built for 5.1, which means that Lua 5.2 cannot find the path of the rock module due to different usage.

The solution to this problem is to download LuaRocks from its github repository Source code and compile it to 5.2

./configure --lua-version=5.2
make build
sudo make install

In order to ensure that I can also install packages for LuaJIT, currently using 5.1 libraries, I also execute the above lines with lua-version = 5.1 in advance (if I execute them later, the default luarocks command will point to 5.1 build.

p>

To build LuaRocks, you need liblua5.2-dev and/or liblua5.1-dev

I installed the luarocks package on Linux Mint, then I have installed a few rocks such as sudo luarocks to install the telescope, but when running the script through lua script.lua, it is required that the module cannot be found.

Meta: Do this Q&A style, because although it exists To answer the question of this question, but there does not seem to be a usual title or easy to find, I hope I can help this person.

In this particular case, the problem It’s just that in my distribution, the default Lua version installed was at the time of writing 5.2, and the LuaRocks package was built for 5.1, which means that Lua 5.2 cannot find the path of the rock module due to different usage.

The solution to this problem is to download the LuaRocks source code from its github repository, And compile it to 5.2

./configure --lua-version=5.2
make build
sudo make install

In order to ensure that I can also install packages for LuaJIT, currently using 5.1 libraries, I also execute the above lines with lua-version = 5.1 in advance (if I execute them later, the default luarocks command will point to 5.1 build.

< p>To build LuaRocks, you need liblua5.2-dev and/or liblua5.1-dev

Leave a Comment

Your email address will not be published.