I am writing a small Lua project and using Luarocks to install my 3rd-party dependencies. The default Lua version on my machine is 5.2 and up to this point everything is working just fine.
However, today I have stumbled across a problem that is confusing me. I want to run my program on Lua 5.1 and Luajit to see if it would also work on those versions but I am having a hard time getting Luarocks to download the appropriate versions of the dependencies. As a last resort hack, I have tried to tell Lua5.1 to use the 5.2 libraries that Luarocks installed (by setting the LUA_PATH
environment variable to the same value as LUA_PATH_5_2
) but unfortunately that is not enough: my project depends on LuaFileSystem, a C-based module, so I'm going to need to have separate versions of it installed for 5.1 and 5.2.
What do I have to do to install both the 5.1 and 5.2 versions of my dependencies? Do I need to pass some parameters to theluarocks install
command? Do I need to have multiple instances of Luarocks installed on my machine? One thing that confuses me is that the inside the .luarocks
folder things are classified under a 5.2 subfolder (~/.luarocks/share/lua/5.2/), suggesting that maybe there could be a way to install things in a sibling 5.1
folder but at the same time there is only one bin
folder, suggesting that luarocks is only able to handle one version of Lua at a time...
~/.luarocks
folder, it's highly likely that you're using a Un*x variant — possibly macOS or Linux — but instructions for either are not 100% identical. Also, if you could clarify what package manager you use (dpkg, rpm, apt, Hmebrew, snap, others...), or, alternatively, state that you prefer to compile everything locally. – Chery