Installing Lua on Windows, macOS, and Linux

· 4 min read · Updated March 18, 2026 · beginner
installation beginner setup

Lua is a lightweight, fast scripting language used in everything from game development (Roblox, LÖVE) to embedded systems and configuration files. Getting started takes just a few minutes.

This guide covers installation on Windows, macOS, and Linux, plus how to verify everything works.

Installing Lua on macOS

The easiest way to install Lua on macOS is through Homebrew, the package manager for macOS.

Install Homebrew (if you have not already)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Lua via Homebrew

Once Homebrew is installed, installing Lua takes one command:

brew install lua

This installs the latest stable version of Lua (currently Lua 5.4).

Verify the Installation

Check that Lua is installed correctly:

lua -v

You should see output like:

Lua 5.4.7  Copyright (C) 1994-2024 Lua.org, PUC-Rio

Installing Lua on Windows

On Windows, you have two main options: the official installer or Scoop (a command-line installer).

Option 1: Official Installer

  1. Visit the Lua downloads page
  2. Download the Windows installer (look for “LuaBinaries” → “Windows Lua binaries”)
  3. Run the installer and follow the prompts

After installation, open PowerShell or Command Prompt and verify:

lua -v

Option 2: Using Scoop

If you prefer a package manager approach, Scoop works well on Windows:

# Install Scoop (run in PowerShell)
iwr -useb get.scoop.sh | iex

# Install Lua
scoop install lua

Verify with:

lua -v

Installing Lua on Linux

Most Linux distributions include Lua in their package repositories. Here are the common methods.

Ubuntu and Debian

sudo apt update
sudo apt install lua5.4

If you want the latest version or additional development files:

sudo apt install lua5.4 liblua5.4-dev

Fedora

sudo dnf install lua

Arch Linux

sudo pacman -S lua

Building from Source (Any Linux Distribution)

For the latest features or if you need a specific version:

# Download Lua source
curl -R -O https://www.lua.org/ftp/lua-5.4.7.tar.gz

# Extract and build
tar zxf lua-5.4.7.tar.gz
cd lua-5.4.7
make linux
sudo make install

Verify with:

lua -v

Running Your First Lua Script

Now that Lua is installed, let us write and run your first script.

Create a Simple Script

Create a file called hello.lua with your favorite text editor:

-- hello.lua
print("Hello, Lua!")

-- Let's do some basic math
local x = 10
local y = 20
local sum = x + y

print(x .. " + " .. y .. " = " .. sum)

-- A simple loop
for i = 1, 3 do
    print("Counting: " .. i)
end

Run the Script

Execute it from your terminal:

lua hello.lua

You should see:

Hello, Lua!
10 + 20 = 30
Counting: 1
Counting: 2
Counting: 3

Interactive Mode

You can also run Lua interactively by typing lua without a file:

lua

This opens the Lua REPL (Read-Eval-Print Loop). Type Lua code and press Enter to execute it immediately. Press Ctrl+D (or Ctrl+Z on Windows) to exit.

Choosing Your Lua Version

Lua has several versions in active use:

  • Lua 5.4 — The latest stable version (5.4.7). Best for new projects.
  • Lua 5.3 — Still widely used, particularly in embedded systems.
  • LuaJIT — A Just-In-Time compiler with excellent performance. Used in many game engines and high-performance applications.

Most beginners should start with Lua 5.4. If you need LuaJIT (for Roblox development you use Luau, a Lua derivative), check your specific platform’s requirements.

Troubleshooting Common Issues

”Command not found” or “lua is not recognized”

  • Ensure the Lua binary directory is in your PATH
  • On Windows, you may need to restart your terminal or computer after installation
  • Try finding the lua executable: where lua (Windows) or which lua (macOS/Linux)

Permission Denied Errors on Linux

If you get permission errors when running sudo make install, make sure you have sudo privileges or the appropriate permissions.

Version Mismatch

Some systems have multiple Lua versions installed. Use lua5.4 or lua5.3 to specify a version explicitly, or check which version is default:

lua -v

Understanding What Lua Is

Lua is a powerful, efficient, lightweight scripting language designed for extending applications. It was created in 1993 at the Pontifical Catholic University of Rio de Janeiro in Brazil, and has grown to become one of the most popular scripting languages for game development and embedded use.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. It is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection.

Key characteristics that make Lua popular include its small footprint—the entire interpreter is under 300KB, making it ideal for embedded systems. LuaJIT can match the performance of compiled languages in many benchmarks. The C API makes it simple to add scripting to any C or C++ application, and Lua runs on virtually any platform that has a C compiler.

Understanding these basics helps you appreciate why Lua is the language of choice for many developers when they need a fast, embeddable scripting solution.

What’s Next?

Now that Lua is installed:

  1. Try the interactive REPL — experiment with basic commands
  2. Modify the hello.lua script — add your own functions and logic
  3. Explore the official Lua documentation for reference

The next tutorial in this series covers Variables and Types in Lua, where you will learn how Lua handles different data types.