Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With multiple versions of Lua installed is it possible to specify which one luarock to install to?

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?

like image 846
vfclists Avatar asked May 21 '15 00:05

vfclists


People also ask

Does Lua have a package manager?

LuaRocks is the package manager for Lua modules. LuaRocks is free software and uses the same license as Lua.

How do I install Lua rocks?

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.

What is the latest version of Lua?

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.


2 Answers

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).

like image 197
siffiejoe Avatar answered Nov 05 '22 10:11

siffiejoe


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.

like image 45
Dhaval Kapil Avatar answered Nov 05 '22 10:11

Dhaval Kapil