Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install multiple versions of Lua on a Linux system (and have them work well with Luarocks)?

Tags:

lua

luarocks

I want to install both Lua 5.2 and 5.1 on my Linux computer. Is this just a matter of installing each version with the usual make linux install or is there something else? In particular, I am worried about the header and library files, since those seem to go on directories that are not namespaced with the version number, such as /usr/local/include.

In addition to that, is it possible to set up Luarocks so that it can install both 5.1 and 5.2 libraries? I know that Luarocks namespaces things in a 5.2 or 5.1 directory, and setting LUA_PATH_5_X and LUA_CPATH_5_X variables should work for configuring Lua after that but I don't understand how Luarocks decides what version of Lua to compile the C libraries against.

like image 994
hugomg Avatar asked Jan 13 '13 16:01

hugomg


2 Answers

You can use luaver for installing, managing and switching between different versions of lua. It is a very easy to use program.

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 114
Dhaval Kapil Avatar answered Sep 21 '22 16:09

Dhaval Kapil


If you want to use make linux install but create a namespace, edit Makefile and change INSTALL_TOP and other variables accordingly.

like image 39
lhf Avatar answered Sep 18 '22 16:09

lhf