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?
LuaRocks is the package manager for Lua modules. LuaRocks is free software and uses the same license as Lua.
To install Luarocks, you first need to install Lua. On Windows and Mac, you can download and install Lua from the website. Once Lua is installed, install Luarocks. If you're on Linux, the luarocks command is available in your distribution's repository.
Its main new features are a new generational mode for garbage collection and const and to-be-closed variables. The current release is Lua 5.4. 4, released on 26 Jan 2022.
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.
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