User Tools

Site Tools


lua-toolchain

Setup The Lua Toolchain

We configure and install a basic Lua toolchain including LuaRocks for additional packages.

Local Installation

We will install Lua and LuaRocks as user in ~/.local

Lua executable will be in ~/.local/bin, man pages in /.local/man.

Let set that path in ~/.profile to the $PATH and $MANPATH

# PATH to $HOME/.local/bin
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
# MANPATH to $HOME/.local/man
if [ -d "$HOME/.local/man" ] ; then
    MANPATH=:"$HOME/.local/man"
fi

Build Lua

Download and unpack latest Lua-5.3 archive http://www.lua.org/ftp

Go inside the extracted archive and type make

$ make
Please do 'make PLATFORM' where PLATFORM is one of these:
   aix bsd c89 freebsd generic linux macosx mingw posix solaris
See doc/readme.html for complete instructions.
It will prompt all the available platform. Choose yours and go head, substitute bsd with your platform and install it locally with one command:
$ make bsd install INSTALL_TOP=$HOME/.local
Check your Lua installation, reload your environment or do a logout and login again. Now, Lua should work, including its man page:
$ lua -v
Lua 5.3.6  Copyright (C) 1994-2020 Lua.org, PUC-Rio
$ man lua

Build LuaRocks

Download and unpack latest luarocks file https://luarocks.github.io/luarocks/releases/

Go inside the extracted archive, tell configure with the prefix to install locally and where are the Lua inclue. Then build and install:

$ ./configure --prefix=$HOME/.local --with-lua-include=$HOME/.local/include
$ make
$ make install

Install local Packages

Lua and LuaRocks should work.

Let's install some local additional packages that would be available for every Lua project.

- Lua formatter

We cannot live anymore without formatting the code. Install luaformatter via the dev repositry as following:

$ luarocks install --server=https://luarocks.org/dev luaformatter

- Lua Check

LuaCheck is a statistic analysis tool and is useful to lint your project. Install LuaCheck as following:

$ luarocks install luacheck

lua-toolchain.txt · Last modified: January 2025 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki