You need two things for this course: a Python environment that runs the lab notebooks, and a standalone Lua 5.4 interpreter with LuaRocks, Lua’s package manager, for scripts and projects. Set up both before you start Module 1. The commands below are for Linux and macOS; on Windows, run them inside the Windows Subsystem for Linux (WSL).
Run every command from the root folder of the repository that holds the course, the folder with
requirements.txt in it.
The notebook environment¶
The labs are Jupyter notebooks. Their %%lua cells use the Lua interpreter built into lupa, a
Python package. The default is Lua 5.4.8. Labs that compile C code or launch a separate Lua
process also use the standalone tools you install below.
Install Python 3.12 and uv, a Python package installer.
Create the environment and install the course’s packages:
uv venv .venv --python 3.12VIRTUAL_ENV=.venv uv pip install -r requirements.txtThe second command ends by listing the packages it installed.
Start JupyterLab:
.venv/bin/jupyter labJupyterLab opens in your browser.
Open
courses/lua101/modules/01-first-steps/lab01.ipynb. Run the first code cell under Setup to load the extension and print the Python and lupa versions. Run the next code cell to seeLua 5.4.
Standalone Lua and LuaRocks¶
From module 1 you also run Lua scripts with the lua command, and from module 6 you install test
tools with LuaRocks. hererocks, which the notebook environment installed, builds both into a
folder of their own. It needs a C compiler: gcc or clang on Linux, and the Xcode Command Line
Tools on macOS (xcode-select --install). On Linux it also needs the headers of GNU Readline, the
library that lets you edit a line and recall earlier ones at the interactive lua prompt. Install
them with sudo apt install libreadline-dev on Debian and Ubuntu, or
sudo dnf install readline-devel on Fedora.
Build Lua 5.4.8 and LuaRocks 3.13.0 into
.venv/lua:.venv/bin/hererocks .venv/lua -l "https://github.com/lua/[email protected]" -r "https://github.com/luarocks/[email protected]"hererocks downloads both from GitHub, builds them, and ends with
Done.The command names the releases from GitHub because hererocks’ own list of Lua versions stops at 5.4.4. Version 5.4.8 matches the language version in the notebooks. The standalone interpreter also supports operations the notebook disables, such asos.exit.If the build stops with
readline/readline.h: No such file or directory, the readline headers are missing. Install them and run the command again, or add--no-readlineto the end of the command. Without readline, scripts run the same, but the interactive prompt can’t edit a line or recall earlier ones.Put the new
luaandluarockscommands first on yourPATHfor this terminal:source .venv/lua/bin/activateRun this again in each new terminal, or add the folder
.venv/lua/binto yourPATHfor good.Check the interpreter:
lua -vIt prints:
Lua 5.4.8 Copyright (C) 1994-2025 Lua.org, PUC-Rio
A system Lua 5.4 interpreter works for the standalone language examples. For Lab 13, use the
hererocks build above. Its C compiler commands look for the interpreter, headers, and static
library under .venv/lua.
Tools for later modules¶
Install these when the module that uses them begins:
| Tool | Module | Install |
|---|---|---|
| LPeg, the parsing library | 4 | luarocks install lpeg, which compiles it with the C compiler from step 1 |
| busted, the test framework | 6 | luarocks install busted |
| luacheck, the linter, and LuaCov, the coverage tool | 11 | luarocks install luacheck and luarocks install luacov |
| StyLua, the formatter | 11 | cargo install stylua --locked --features lua54, or a release from StyLua’s GitHub page; a build without lua54 can’t read <close> |
| lua-language-server, the type checker | 11 | A release from lua-language-server’s site |
| A C compiler and the Lua headers | 13 | The compiler from step 1 above; hererocks already installed the headers in .venv/lua/include |
The course’s examples were checked with LPeg 1.1.0, busted 2.3.0, luacheck 1.2.0, LuaCov 0.17.0, StyLua 2.6.0, and lua-language-server 3.19.2.