3

I have started learning lua programming and have installed lua using below commands

sudo apt install lua5.3 liblua5.3-dev

but when I do $ lua

I get this warning

Command 'lua' not found, but can be installed with:

sudo apt install lua5.1 sudo apt install lua5.2 sudo apt install lua50

Eka
  • 3,017

1 Answers1

4

Commonly, when a distribution provides multiple versions (or multiple implementations) of a program, the update-alternatives mechanism is used to determine which one is run. This seems to be the case in general for lua ex. on my 18.04 box:

$ ls -l $(which lua)
lrwxrwxrwx 1 root root 33 Apr 17  2020 /usr/bin/lua -> /etc/alternatives/lua-interpreter

$ update-alternatives --query lua-interpreter Name: lua-interpreter Link: /usr/bin/lua Slaves: lua-manual /usr/share/man/man1/lua.1.gz Status: auto Best: /usr/bin/lua5.2 Value: /usr/bin/lua5.2

Alternative: /usr/bin/lua5.2 Priority: 120 Slaves: lua-manual /usr/share/man/man1/lua5.2.1.gz

In the case of lua5.3 it seems that the new alternative does not get added by the package - see for example Debian Bug report logs - #863036 lua5.3 is not available in update-alternatives for lua(interpreter|compiler)

You can add the version manually (choosing a suitably higher priority if you want it to be the default) ex.

sudo update-alternatives --install /usr/bin/lua lua-interpreter /usr/bin/lua5.3 130 \
  --slave /usr/share/man/man1/lua.1.gz lua-manual /usr/share/man/man1/lua5.3.1.gz

after which you should see

$ lua -v
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio

You will probably want to do the same for lua-compiler:

sudo update-alternatives --install /usr/bin/luac lua-compiler /usr/bin/luac5.3 130 \
  --slave /usr/share/man/man1/luac.1.gz lua-compiler-manual /usr/share/man/man1/luac5.3.1.gz
steeldriver
  • 143,099