Arch keeps Lua in the official repositories, so the cleanest way to install Lua on Arch Linux is through pacman rather than source builds or AUR helpers. Use the lua package for the current interpreter, add compatibility packages only when a project needs a specific Lua branch, and install modules through pacman or LuaRocks depending on whether you want system-managed packages or project/user-managed rocks.
Current Arch packaging makes Lua 5.5 the default lua branch, while lua54, lua53, lua52, lua51, and luajit remain available for compatibility. That split matters for binaries, headers, and modules because each major.minor Lua branch uses its own command name, include directory, and module search path.
Update Arch Linux Before Installing Lua
Synchronize package databases and apply available updates before installing Lua packages. Arch is a rolling-release distribution, so a current package database helps avoid partial-upgrade dependency conflicts.
sudo pacman -Syu
These commands use
sudofor tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.
Install Lua on Arch Linux
The official Arch repositories provide the current Lua branch, older compatibility branches, LuaJIT, LuaRocks, and many common Lua modules. Start with the lua package unless a project explicitly documents another branch.
| Package | Branch or Role | Commands | Use When |
|---|---|---|---|
| lua | Current Arch default, currently Lua 5.5 | lua, luac | New scripts, general development, default Lua headers |
| lua54 | Lua 5.4 compatibility | lua5.4, luac5.4 | Projects that have not moved to Lua 5.5 yet |
| lua53 | Lua 5.3 compatibility | lua5.3, luac5.3 | Older libraries, embedded applications, compatibility testing |
| lua52 | Lua 5.2 compatibility | lua5.2, luac5.2 | Legacy applications that still require Lua 5.2 |
| lua51 | Lua 5.1 compatibility | lua5.1, luac5.1 | Old plugins, addons, and LuaJIT-adjacent compatibility checks |
| luajit | Lua 5.1-compatible JIT runtime | luajit | Software that requires LuaJIT or its FFI extension |
For broader Arch-specific Lua notes, the Arch Wiki Lua page is a useful reference. Because Arch is a rolling release, package release numbers in output examples may move after publication; use the branch and pacman owner as the stable checks.
Install the Current Lua Package
Install the default Lua interpreter and bytecode compiler from the official repository:
sudo pacman -S lua
Verify the interpreter and package ownership:
lua -v
command -v lua
pacman -Qo /usr/bin/lua
Relevant output should show the current Arch Lua branch and confirm that pacman owns the binary:
Lua 5.5.0 Copyright (C) 1994-2025 Lua.org, PUC-Rio /usr/bin/lua /usr/bin/lua is owned by lua 5.5.0-2
Install Lua Compatibility Packages
Install older Lua branches only when a project requires that branch. The packages can coexist because Arch gives each compatibility interpreter a versioned command name.
sudo pacman -S lua54 lua53 lua52 lua51
Check the versioned commands after installation:
lua5.4 -v
lua5.3 -v
lua5.2 -v
lua5.1 -v
Lua 5.4.8 Copyright (C) 1994-2025 Lua.org, PUC-Rio Lua 5.3.6 Copyright (C) 1994-2020 Lua.org, PUC-Rio Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
Install LuaJIT on Arch Linux
LuaJIT is a Lua 5.1-compatible runtime with a just-in-time compiler and FFI support for calling C libraries. Install it when an application specifically asks for LuaJIT, OpenResty-style Lua, or Lua 5.1 semantics with LuaJIT extensions.
sudo pacman -S luajit
Verify the installed LuaJIT command:
luajit -v
command -v luajit
pacman -Qo /usr/bin/luajit
LuaJIT 2.1.1774896198 -- Copyright (C) 2005-2026 Mike Pall. https://luajit.org/ /usr/bin/luajit /usr/bin/luajit is owned by luajit 2.1.1774896198+18b087c-1
LuaJIT is not a drop-in replacement for Lua 5.2, 5.3, 5.4, or 5.5 syntax. Use standard Lua for scripts that rely on newer language features, and use LuaJIT when the target application documents Lua 5.1 or LuaJIT support.
Install Lua Headers on Arch Linux
Arch does not use separate lua-dev or lua-devel package names for the main interpreter. The interpreter package for each branch also provides that branch’s headers and pkg-config files, so the default lua package owns /usr/include/lua.h, while compatibility branches use versioned include directories.
pacman -Ql lua | grep '/include/.*\.h$'
lua /usr/include/lauxlib.h lua /usr/include/lua.h lua /usr/include/luaconf.h lua /usr/include/lualib.h
If you know the missing header path from a compiler error, refresh the file database and ask pacman which package provides it. This lookup works even before the compatibility package is installed:
sudo pacman -Fy
pacman -F usr/include/lua.h
pacman -F usr/include/lua5.4/lua.h
pacman -F usr/include/lua5.1/lua.h
pacman -F usr/include/luajit-2.1/lua.h
usr/include/lua.h is owned by extra/lua 5.5.0-2 usr/include/lua5.4/lua.h is owned by extra/lua54 5.4.8-6 usr/include/lua5.1/lua.h is owned by extra/lua51 5.1.5-13 usr/include/luajit-2.1/lua.h is owned by extra/luajit 2.1.1774896198+18b087c-1
Install Lua Modules and LuaRocks on Arch Linux
Lua modules can come from Arch packages or from LuaRocks. Prefer pacman when the module exists in the official repositories because pacman handles updates and file ownership. Use LuaRocks for project-specific modules, user-local modules, or rocks that Arch does not package.
| Module Source | Managed By | Update Path | Best For |
|---|---|---|---|
Arch lua-* packages | pacman | System updates | System-wide modules, packaged applications, clean removal |
| LuaRocks | LuaRocks | LuaRocks commands | Project-specific modules, un-packaged rocks, exact rock versions |
Install Lua Modules with Pacman
Search the official repositories for modules built for the current Lua branch:
pacman -Ss '^lua-' | head -20
extra/lua-alt-getopt 0.8.0-3
Lua module for processing options similar to getopt_long(3) for Lua 5.5
extra/lua-argparse 0.7.2-1
Feature-rich command line parser for Lua 5.5
extra/lua-basexx 0.4.1-4
A Lua library which provides base encoding and decoding for Lua 5.5
Install only the modules your project needs. This example installs filesystem, socket, and JSON modules for the default Lua branch:
sudo pacman -S lua-filesystem lua-socket lua-dkjson
Verify a packaged module by requiring it from Lua:
lua -e 'local json = require("dkjson"); print(json.encode({name="test", value=42}))'
{"value":42,"name":"test"}
JSON object key order is not significant. If your output shows
{"name":"test","value":42}instead, the module is still working correctly.
Install LuaRocks on Arch Linux
Install LuaRocks from the official repository when you need modules from luarocks.org or a project-specific rock tree:
sudo pacman -S luarocks
Check the LuaRocks version and the Lua branch it targets by default:
luarocks --version
luarocks config lua_version
/usr/bin/luarocks 3.13.0 LuaRocks main command-line interface 5.5
The Arch luarocks package follows the default lua branch. Use --lua-version only when you have installed the matching compatibility interpreter and the rock supports that Lua version.
Install User-Local Modules with LuaRocks
For modules that do not need to be system packages, install them under your home directory and load the LuaRocks path in the current terminal session. This avoids mixing pacman-owned files with manually installed rocks under /usr.
luarocks --local install inspect
eval "$(luarocks path)"
lua -e 'local inspect = require("inspect"); print(type(inspect))'
table
If a rock builds native code and fails because compiler tools are missing, install Arch’s base development toolchain before retrying. For more compiler context, see the guide on how to install GCC on Arch Linux.
sudo pacman -S --needed base-devel
Install Lua Language Server on Arch Linux
For editor diagnostics, completion, and LSP integration, install the packaged Lua Language Server separately. It is tooling for editors and does not replace the lua interpreter.
sudo pacman -S lua-language-server
Verify the package and command ownership:
lua-language-server --version
command -v lua-language-server
pacman -Qo /usr/bin/lua-language-server
3.18.2-dev /usr/bin/lua-language-server /usr/bin/lua-language-server is owned by lua-language-server 3.18.2-1
Test Lua on Arch Linux
Run a one-liner first to confirm the interpreter can execute code:
lua -e 'print("Hello from " .. _VERSION)'
Hello from Lua 5.5
Create and run a short script when you want to check normal file execution:
cat > hello.lua <<'EOF'
print("Hello from " .. _VERSION)
local function greet(name)
return "Welcome, " .. name .. "!"
end
print(greet(os.getenv("USER") or "Arch user"))
EOF
lua hello.lua
rm hello.lua
Hello from Lua 5.5 Welcome, your-user!
Launch the interactive interpreter with lua when you want a REPL. Exit with Ctrl+D or by typing os.exit().
Troubleshoot Lua on Arch Linux
Most Lua problems on Arch come from branch mismatches: a module was installed for one Lua version, while the application runs another interpreter.
Fix Lua Module Not Found Errors
A missing-module error usually means the module is not installed for the Lua branch that ran the script.
lua: script.lua:1: module 'dkjson' not found:
no field package.preload['dkjson']
no file '/usr/share/lua/5.5/dkjson.lua'
Check the interpreter version and module paths:
lua -v
lua -e 'print(package.path)'
lua -e 'print(package.cpath)'
If the script uses default Lua, install the module with pacman when available:
sudo pacman -S lua-dkjson
If the script uses LuaJIT or an older Lua branch, call that interpreter directly and install a branch-compatible module package or rock. Do not assume a module installed for Lua 5.5 will load under lua5.1 or luajit.
lua5.1 script.lua
luajit script.lua
luarocks --lua-version 5.1 search dkjson
Fix Missing lua.h Header Errors
If a build fails with lua.h: No such file or directory, identify the Lua branch the build expects. The current lua package provides /usr/include/lua.h; compatibility branches provide versioned paths such as /usr/include/lua5.4/lua.h.
sudo pacman -Fy
pacman -F usr/include/lua.h
pacman -F usr/include/lua5.4/lua.h
pacman -F usr/include/lua5.1/lua.h
Install the package that owns the header path your build system expects:
sudo pacman -S lua
sudo pacman -S lua54
sudo pacman -S lua51
Fix LuaRocks Compilation Failures
Rocks that include C code need compiler tools and any external libraries they bind to. Install base-devel for the normal Arch build toolchain, then install any library named by the rock’s error output.
sudo pacman -S --needed base-devel
For example, TLS-related Lua modules may also need OpenSSL headers and libraries:
sudo pacman -S --needed openssl
Fix the Wrong Lua Version Running
Check the command path and package owner when a script runs a different Lua branch than expected:
command -v lua
lua -v
pacman -Qo "$(command -v lua)"
Run the versioned interpreter directly when the project requires one:
lua5.4 script.lua
lua5.3 script.lua
lua5.1 script.lua
luajit script.lua
For executable scripts that must always use a specific branch, update the shebang to the versioned command:
#!/usr/bin/env lua5.4
Remove Lua from Arch Linux
Remove only the Lua packages and modules you installed. On a developer workstation, another application may depend on Lua, so check reverse dependencies before removing the default interpreter.
pacman -Qi lua | grep -E '^(Required By|Optional For)'
If pacman refuses to remove
luabecause another installed package requires it, keep Lua installed or remove the dependent application first. Do not use force-removal flags to break package dependencies.
Remove LuaRocks first if you installed it:
sudo pacman -Rns luarocks
Remove example pacman-installed modules if you no longer need them:
sudo pacman -Rns lua-filesystem lua-socket lua-dkjson
If pacman reports that another Lua module depends on one of those packages, remove the dependent module in the same transaction or keep the shared module installed.
Remove compatibility interpreters and LuaJIT if they were installed only for this workflow:
sudo pacman -Rns luajit lua54 lua53 lua52 lua51
Remove the default Lua package only after confirming no required package still depends on it:
sudo pacman -Rns lua
Verify the main packages are no longer installed:
pacman -Q lua luarocks luajit lua54 lua53 lua52 lua51 2>&1
error: package 'lua' was not found error: package 'luarocks' was not found error: package 'luajit' was not found error: package 'lua54' was not found error: package 'lua53' was not found error: package 'lua52' was not found error: package 'lua51' was not found
If you used luarocks --local and want to delete user-local rocks as well, remove the LuaRocks directory under your home folder. Skip this step if you plan to reinstall LuaRocks and keep your local modules.
This deletes every user-local rock under
~/.luarocks, not only modules installed while following these Lua setup steps.
rm -rf ~/.luarocks
Conclusion
Pacman covers the normal Lua setup on Arch: install lua for the current branch, add versioned packages only for compatibility, and choose pacman modules before LuaRocks when system ownership matters. After that, connect Lua scripts to local data with SQLite on Arch Linux, use PostgreSQL on Arch Linux for larger applications, or keep deployment experiments isolated with Docker on Arch Linux.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>