Install Lua on Windows

Installing Lua on Windows is straightforward using pre-compiled binaries or through package managers like Chocolatey and Scoop.

Using Chocolatey (Recommended)

Chocolatey is a popular package manager for Windows that makes installing Lua simple.

  1. Install Chocolatey if you haven’t already:

    • Open PowerShell as Administrator
    • Run: Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  2. Install Lua:

choco install lua
  1. Verify installation:
lua -v

Using Scoop

Scoop is another excellent package manager for Windows:

  1. Install Scoop if you haven’t already:

    • Open PowerShell as Administrator
    • Run: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    • Run: irm get.scoop.sh | iex
  2. Install Lua:

scoop install lua

Manual Installation

If you prefer manual installation or need a specific version:

  1. Download Lua from the official website
  2. Extract the ZIP file to a location like C:\lua
  3. Add C:\lua to your system PATH environment variable
  4. Open Command Prompt and verify:
lua -v

Using MSYS2/MinGW

For developers who prefer a Unix-like environment:

  1. Install MSYS2 from msys2.org
  2. Open MSYS2 MinGW 64-bit terminal
  3. Install Lua:
pacman -S mingw-w64-x86_64-lua

Verifying Installation

Test your installation by creating a test file:

  1. Create a file named test.lua with this content:
print("Hello from Lua on Windows!")
print("Lua version:", _VERSION)
print("OS:", package.config:sub(1,1) == "\\" and "Windows" or "Unix")
  1. Run it from Command Prompt:
lua test.lua

Using Lua in Windows

Once installed, you can use Lua in several ways:

Command Line:

lua script.lua

Interactive Mode:

lua

Compile to Bytecode:

luac script.lua

IDE Integration

Windows IDEs with excellent Lua support:

  • Visual Studio Code: Install the “Lua” extension
  • Notepad++: Install the “Lua” language plugin
  • Sublime Text: Use the “Lua” package
  • ZeroBrane Studio: Dedicated Lua IDE with debugger

Common Windows Issues

PATH not found: Restart Command Prompt or PowerShell after adding Lua to PATH.

Permission denied: Run Command Prompt as Administrator when installing to system directories.

DLL errors: Ensure Visual C++ Redistributable is installed, usually included with Windows 10/11.

Next Steps

With Lua successfully installed on Windows, you can start exploring our Lua basics tutorials or install LuaRocks for package management.

For Windows-specific Lua discussions and support, check the Lua mailing list.

Last updated on