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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With