Skip to content

Installation instructions for Unix

Hisham Muhammad edited this page Aug 28, 2019 · 11 revisions

First of all, get the latest ".tar.gz" package here.

The LuaRocks build system for Unix is based on a simple "configure" script and a Makefile. The "configure" script offers some flags that are useful for different models of use of LuaRocks. Run ./configure --help for details.

Note that if you are running macOS and using Homebrew, installing the lua package installs LuaRocks by default, so there is nothing to do!

Quick start

1.Ubuntu/Debian user

To get a default installation of Lua and LuaRocks under /usr/local:

  • First, ensure that you have development tools installed on your system, otherwise run the command below to install them.
 -$ sudo apt install build-essential libreadline-dev
  • Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it.
-$ curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz
-$ tar -zxf lua-5.3.4.tar.gz
-$ cd lua-5.3.4
-$ make linux test
-$ sudo make install

now Lua is installed.

  • Download and unpack the LuaRocks tarball using following commands. (We use version 3.1.3 here; a previous "long term stable" version was 3.0.4.)
-$ wget https://luarocks.org/releases/luarocks-3.2.0.tar.gz
-$ tar zxpf luarocks-3.2.0.tar.gz
-$ cd luarocks-3.2.0
  • Run ./configure. (This will attempt to detect your installation of Lua. If you get any error messages, see the section "Customizing your settings", below.)
  • Run make build.
  • As superuser, run make install.

For more information and installation options, read on!

2. Other users

To get a default installation of Lua and LuaRocks under /usr/local:

  • Install Lua, using the appropriate methods for your system: for compiling Lua modules written in C you'll need the Lua library and headers (often available as a Lua "development" package in most distributions).
  • Download and unpack the LuaRocks tarball.
  • Run ./configure. (This will attempt to detect your installation of Lua. If you get any error messages, see the section "Customizing your settings", below.)
  • Run make build.
  • As superuser, run make install.

For more information and installation options, read on!

The default settings

The default settings are suitable for installing LuaRocks globally in your system while allowing both system-wide and per-user sets of rocks. User accounts will be able to install their own rocks in their $HOME directory, and the superuser can install rocks that will be available for everyone.

By default LuaRocks will install itself in /usr/local, like Lua, and will use /usr/local/etc/luarocks/config.lua as a default path for the configuration file. The default system-wide rocks trees is configured as /usr/local/lib/luarocks, and per-user rocks install at $HOME/.luarocks/rocks/. Command-line scripts provided by rocks will be installed in /usr/local/lib/luarocks/bin/ or $HOME/.luarocks/bin/, respectively. The user may then add these directories to their $PATH variable.

Customizing your settings

All paths described above can be overridden with flags in the configure script, or entries in the configuration file.

Flag Desciption
--prefix=DIR Prefix where LuaRocks should be installed. Default is /usr/local
--sysconfdir=DIR Location where the config file should be installed. Default is $PREFIX/etc/luarocks
--rocks-tree=FILE Root of the local tree of installed rocks. Default is $PREFIX/lib/luarocks
--lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. Default is "" (lua...)
--lua-version=VERSION Use specific Lua version: 5.1 or 5.2. Default is "5.1"
--with-lua=PREFIX Use Lua from given prefix. Default is /usr
--with-lua-include=DIR You can also specify Lua's includes dir. Default is $LUA_DIR/include
--with-lua-lib=DIR You can also specify Lua's libraries dir. Default is $LUA_DIR/lib
--with-downloader=TOOL Which tool to use as a downloader. Valid options are: wget, curl. Default is to auto-detect.
--with-md5-checker=TOOL Which tool to use as a download checker. Valid options are: md5sum, openssl. Default is to auto-detect.
--versioned-rocks-dir Use a versioned rocks dir, such as $PREFIX/lib/luarocks/rocks-5.1/. Default is to auto-detect the necessity.
--force-config Use a single config location. Do not use the $LUAROCKS_CONFIG variable or the user's home directory. Useful for locking down a configuration when [[Embedding in an application

After installation, a default config file called config.lua will be installed at the directory defined by --sysconfdir. For further configuration of LuaRocks paths, see the Config file format.

Installing LuaRocks as a rock

The "Quick Start" option above installs LuaRocks as a regular system package, under /usr/local. Alternatively, LuaRocks can install itself as a rock: instead of make build and sudo make install, just run make bootstrap (this builds and installs LuaRocks, so there is no second make install step).

Two installation options are provided because they are useful for different scenarios:

  • Linux distribution mantainers will usually package LuaRocks as a regular package (i.e. not as a rock), so that the system package manager takes control of the installed files that comprise LuaRocks, and LuaRocks doesn't modify files that are being tracked by the system database.
  • End-users installing LuaRocks from sources can benefit from installing it as a rock, so that they can upgrade to new versions later by running luarocks install luarocks.

Next steps

Once LuaRocks is installed, learn more about Using LuaRocks.

You can’t perform that action at this time.