Lua cannot find LuaRocks-installed modules on Linux
Asked Answered
U

2

5

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.

Unofficial answered 1/9, 2014 at 9:0 Comment(0)
U
6

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

Unofficial answered 1/9, 2014 at 9:0 Comment(0)
D
3

The solution for me is this.

I try

eval "$(luarocks path)"

and it works.

Hope it works for others.

Devaluation answered 14/1, 2019 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.