Turn a Lua script into a program you can hand to someone else.
luainstaller collects your script, the modules it loads with require, and the Lua
runtime, and builds a native executable from them. The person running it
doesn’t need Lua installed.
luai -b app/main.lua -o build/app # (1)
build/app/app # (2)-
Build a directory bundle from your entry script.
-
Run it. No
luaon the machine is required.
It works with official Lua 5.1 through 5.5 on Linux, Windows (back to XP), macOS, FreeBSD and Android/Termux.
luarocks install luainstaller
luai -vLuaRocks is optional. Without it, install from a source checkout into a directory of your choice:
lua tools/install.lua --prefix "$HOME/luainstaller"
export PATH="$HOME/luainstaller/bin:$PATH"Details, including Windows and moving or removing an install, are in Installing without LuaRocks.
-
An official Lua interpreter, 5.1 to 5.5. LuaJIT isn’t supported.
-
A C compiler for the machine you’re on.
-
Lua headers and a Lua library that match that interpreter’s version.
Analysis works with just Lua. Only building needs the compiler.
|
💡
|
On most Linux systems the headers come from a package such as
liblua5.4-dev or lua-devel.
|
The safe path is: check the dependencies, build a folder, test the folder, and only then make a single file.
-
See what will be packaged.
luai -a app/main.lua
This lists every module
luainstallerfound for your script. If something is missing here, it will be missing from the executable too. -
Build a directory bundle.
luai -b app/main.lua -o build/app
You get
build/app/app(orapp.exeon Windows) plus a hidden.luai/folder with native modules and license files. -
Test it the way your users will run it.
env -u LUA_PATH -u LUA_CPATH build/app/app
Clearing the Lua search paths makes sure the program isn’t quietly loading modules from your own machine.
-
Make a single file, if you want one.
luai -b --file app/main.lua -o build/app-onefile
The single file unpacks itself to a temporary folder on first run and starts from there.
|
❗
|
If the single file misbehaves, go back to the directory bundle. It shows exactly what was packaged, so problems are much easier to find. |
The same tool answers to two names. Pick whichever you like, but don’t mix them in one command.
| Task | luai (short options) | luainstaller (subcommands) |
|---|---|---|
Analyze |
|
|
Trace |
|
|
Build |
|
|
Version |
|
|
Help |
|
|
View logs |
|
|
--dir / --file
|
folder bundle (default) or single executable |
-o PATH
|
where to write the result |
--max-deps N
|
raise this for large programs; the default is 36 |
--include FILE
|
add a module the scan couldn’t see |
-d runtime
|
find dependencies by actually running the script |
Everything else is in the usage guide.
The same features are available as a library:
local luainstaller = require("luainstaller")
local result = luainstaller.bundle({
entry = "app/main.lua",
out = "build/app",
})
if result.ok then
print("built " .. result.executable)
else
print(result.error.type .. ": " .. result.error.message)
endEvery call returns a table with ok. On failure, error.type names the
problem. Options match the command line; see
Library API.
luainstaller builds for the machine it runs on. To get a Windows
executable, build on Windows; for macOS, build on a Mac.
| System | CPU | Notes |
|---|---|---|
Windows XP SP3 and later |
x86, x86_64 |
Needs an XP-capable compiler and runtime.[1] |
Windows 7 and later |
x86, x86_64, ARM, ARM64 |
MSVC or MinGW |
Linux |
x86, x86_64, ARM, ARM64 |
Shared or static Lua |
macOS |
x86_64, ARM64 |
Static Lua preferred |
FreeBSD |
native |
|
Android (Termux) |
native |
Runs inside the Termux app |
Other Unix-like systems often work too, as long as the compiler and Lua library match.
|
🔥
|
Native C modules (anything built as |
Installing without LuaRocks, on Linux, macOS and Windows |
|
All options, dependency discovery, native modules, the library API |
|
Common errors and how to fix them |
|
Compilers per system, Windows XP, native modules, what’s out of scope |
|
What’s inside a bundle and how it starts |
|
What to keep when you redistribute an executable |
|
Changes between releases |
For contributors
-
Implementation notes — how the code is laid out
-
Testing — test suites and CI
luainstaller is released under the
GNU LGPL, version 3 or later.
Every bundle includes the Lua license, the luainstaller license, and the
generated C source, so you can pass it on as-is. Keep the .luai/ folder
when you redistribute. Relinking explains why.