Install LuaRocks

LuaRocks installation varies by operating system. Follow the instructions for your system below to get LuaRocks up and running.

Linux Installation

Ubuntu/Debian

sudo apt update
sudo apt install luarocks

CentOS/RHEL/Fedora

# For Fedora
sudo dnf install luarocks

# For CentOS/RHEL
sudo yum install luarocks

Arch Linux

sudo pacman -S luarocks

From Source (Recommended for latest version)

If the package manager version is outdated:

# Download latest version
wget https://luarocks.org/releases/luarocks-3.9.2.tar.gz
tar zxpf luarocks-3.9.2.tar.gz
cd luarocks-3.9.2

# Configure and install
./configure
make
sudo make install

macOS Installation

Using Homebrew (Recommended)

brew install luarocks

Using MacPorts

sudo port install luarocks

From Source

If you prefer manual installation or need the latest version:

# Install Xcode Command Line Tools if not already installed
xcode-select --install

# Download and compile
curl -R -O https://luarocks.org/releases/luarocks-3.9.2.tar.gz
tar zxf luarocks-3.9.2.tar.gz
cd luarocks-3.9.2

./configure && make && sudo make install

Windows Installation

Using Chocolatey

choco install luarocks

Manual Installation

  1. Download the Windows installer from luarocks.org
  2. Run the installer
  3. Follow the installation wizard
  4. Ensure Lua is installed first (see Lua installation guide)

Verifying Installation

After installation, verify LuaRocks is working:

luarocks --version

You should see output like:

LuaRocks 3.9.2

Configuration

LuaRocks automatically detects your Lua installation. To check configuration:

luarocks config

This shows your Lua version, tree locations, and other settings.

Common Installation Issues

Permission Errors

If you encounter permission errors:

# On Unix-like systems
sudo chown -R $USER ~/.luarocks

Path Issues

Ensure LuaRocks is in your PATH:

# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
export PATH=$PATH:~/.luarocks/bin

Multiple Lua Versions

If you have multiple Lua versions installed:

# Specify Lua version during configuration
./configure --with-lua=/usr/bin/lua5.4

Next Steps

With LuaRocks installed, learn how to use LuaRocks to install and manage Lua packages.

For more installation details and troubleshooting, visit the LuaRocks documentation.

Last updated on