I have both Lua 5.1
and Lua 5.2
installed on Linux. When using luarocks
to install a package is it possible to pass on option to luarocks that specifies which version of Lua the rock should be installed for?
Not a command line option, but you may have different variants of the LuaRocks command line program available (luarocks-5.1
and luarocks-5.2
) if you installed LuaRocks for both Lua versions.
You can do so from source using (assuming a Debian/Ubuntu-like lua5.1
executable):
./configure --lua-version=5.1 --lua-suffix=5.1 --versioned-rocks-dir
# make sure that you got the correct Lua executable and include directory
sudo make bootstrap
and the same for Lua 5.2.
In case configure
's auto-detection does not find the correct executables/directories, the following flags might be of help:
--with-lua-bin=DIR
(directory where the Lua executable is installed)--with-lua-include=DIR
(directory where the Lua include files are)--with-lua-lib=DIR
(you probably don't need this one on Linux)
When you have done that, luarocks-5.1 install some-package
installs the given package for Lua 5.1, and luarocks-5.2 install some-package
installs that same package for Lua 5.2.
If LuaRocks was installed via a package manager, multiple Lua versions may or may not be supported (e.g. the Debian/Ubuntu package is configured for Lua 5.1 only).
You can use luaver for installing, managing and switching between different versions of lua, luarocks.
To install luaver
run:
curl https://raw.githubusercontent.com/dhavalkapil/luaver/master/install.sh -o install.sh && . ./install.sh
Then you can install and use multiple versions of lua as follows:
luaver install 5.3.1 # Installs lua version 5.3.1
luaver install 5.3.0 # Installs lua version 5.3.0
luaver use 5.3.1 # Switches to lua version 5.3.1
See https://dhavalkapil.com/luaver/ for more details.
© 2022 - 2024 — McMap. All rights reserved.