Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua cannot find LuaRocks-installed modules on Linux

I installed the luarocks package on Linux Mint, and afterwards installed a couple of rocks such as sudo luarocks install telescope, but when running a script via lua script.lua, require cannot find the module.

Meta: Doing this Q&A style, because while questions that answer this exist, none seem to be generically titled or easily findable, and I hope that I can help someone with this.

like image 891
Llamageddon Avatar asked Feb 13 '23 03:02

Llamageddon


1 Answers

In this specific case, the problem was simply that on my distribution, the default Lua version installed was at the time of writing this 5.2, whereas the LuaRocks package was built for 5.1, meaning that Lua 5.2 could not find the rocks due to using different paths for modules.

The solution to the problem was downloading the LuaRocks source code from its github repository, and compiling it for 5.2

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

To make sure I can also install packages for LuaJIT, which as of the moment uses 5.1 libs, I have also executed the above lines with lua-version=5.1 beforehand (if I executed them after, the default luarocks command would point at the 5.1 build.

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

like image 131
Llamageddon Avatar answered Feb 15 '23 09:02

Llamageddon