Standalone executables
luneblox build turns a script into a single executable that runs without luneblox installed.
luneblox build tool.luau./tool arg1 arg2Compiling standalone binary from tool.luauWriting standalone binary to toolHow it works
Section titled “How it works”- The input file is compiled to Luau bytecode.
- A base executable is chosen: the running
lunebloxitself, or alunebloxbuilt for the target. - The bytecode is appended to a copy of the base executable, followed by its length and a marker.
- The result is written to the output path and marked executable.
When any luneblox binary starts, it checks whether its own file ends with that marker. If it does,
it runs the embedded bytecode instead of acting as the CLI. A standalone executable is therefore the
whole runtime plus your script: every @lune/* library is available in it.
Arguments
Section titled “Arguments”A standalone executable has no subcommands. Every argument after the executable name goes to the
script in process.args:
--!strictlocal process = require("@lune/process")print(process.args)luneblox build tool.luau./tool --verbose input.txtThe script sees --verbose and input.txt.
The exit code follows the same rules as luneblox run: the process.exit code if there is one,
otherwise 1 after an uncaught error and 0 without one.
One file only
Section titled “One file only”If your script is split across modules, combine it into one file before building.
The input is read as a file path exactly as given. Unlike luneblox run, the script folders are not
searched and the extension cannot be left out.
Output
Section titled “Output”--output (-o) sets the path to write:
luneblox build tool.luau --output dist/toolWithout it, the output is the input path with its .luau or .lua extension removed: tool.luau
becomes tool.
- For a Windows target,
.exeis added when the output path does not already end in it. - The output cannot be the same path as the input. An input file that has no extension needs
--output. - An existing file at the output path is overwritten.
- On Unix the file is created with mode
755.
Target
Section titled “Target”--target (-t) builds for another operating system or architecture:
luneblox build tool.luau --target windows-x86_64luneblox build tool.luau --target linux-aarch64 --output dist/tool-linux-arm64A target is written os-arch:
| OS | Architecture |
|---|---|
windows (or win) |
x86_64 (or x64) |
linux |
aarch64 (or arm64) |
macos (or mac, darwin) |
Without --target, or when the target is the system luneblox is running on, the base executable is
the running luneblox and nothing is downloaded.
Base executables for other targets
Section titled “Base executables for other targets”For any other target, luneblox needs a luneblox binary built for that target. It downloads one
from the LuneBlox release with the same version as the luneblox you are running:
https://github.com/XopoIII/LuneBlox/releases/download/v<version>/luneblox-<version>-<os>-<arch>.zipRequested target 'linux-aarch64' does not exist in cacheDownloading luneblox-0.11.3-linux-aarch64...Downloaded successfully and added to cacheBase executables come from LuneBlox’s own releases, not Lune’s. A standalone executable built for another target has to carry the same Luau as one built for this one.
If the release has no archive for the target, the build fails with
failed to find lune target '<target>' in GitHub release. A locally built development version has
no release, so it can only build for its own system.
The cache
Section titled “The cache”The binary is taken out of the archive and stored in the target folder of the cache directory,
named after the target:
<cache directory>/target/ linux-aarch64 linux-x86_64 macos-x86_64 windows-x86_64exeLater builds for the same target use the cached file and make no request. The file name does not
include the version, so after upgrading luneblox, delete the target folder to have the base
executables downloaded again for the new version.
LUNEBLOX_CACHE moves the cache directory, which is useful in CI:
LUNEBLOX_CACHE=.cache/luneblox luneblox build tool.luau --target linux-x86_64Directories says where the cache directory is on each platform.
Luau and fast flags
Section titled “Luau and fast flags”The bytecode is compiled at optimization level 2 with debug level 1, so error messages carry line numbers.
Luau’s fast flags are set to the live Roblox client’s values before the script is compiled, because some flags change what the compiler emits. The standalone executable sets them again when it starts, before it runs the bytecode.
LUNE_ROBLOX_FFLAGS=0 is read at both moments. Set it when building to compile with Luau’s default
flags, and when running the executable to run with them. See Fast flags.
A standalone executable does not read LUNE_LUAU_JIT; it runs with native code generation off.
Building for every target
Section titled “Building for every target”for target in linux-x86_64 linux-aarch64 macos-x86_64 macos-aarch64 windows-x86_64 windows-aarch64; do luneblox build tool.luau --target "$target" --output "dist/tool-$target"doneThe Windows outputs get .exe added.
