Search code examples
luaconflicting-librariesluarocks

With multiple versions of Lua installed is it possible to specify which one luarock to install to?


I have both Lua 5.1 and Lua 5.2 installed on Linux. When using luarocks to install a package is it possible to pass on option to luarocks that specifies which version of Lua the rock should be installed for?


Solution

  • Not a command line option, but you may have different variants of the LuaRocks command line program available (luarocks-5.1 and luarocks-5.2) if you installed LuaRocks for both Lua versions.

    You can do so from source using (assuming a Debian/Ubuntu-like lua5.1 executable):

    ./configure --lua-version=5.1 --lua-suffix=5.1 --versioned-rocks-dir
    # make sure that you got the correct Lua executable and include directory
    sudo make bootstrap
    

    and the same for Lua 5.2.

    In case configure's auto-detection does not find the correct executables/directories, the following flags might be of help:

    • --with-lua-bin=DIR (directory where the Lua executable is installed)
    • --with-lua-include=DIR (directory where the Lua include files are)
    • --with-lua-lib=DIR (you probably don't need this one on Linux)

    When you have done that, luarocks-5.1 install some-package installs the given package for Lua 5.1, and luarocks-5.2 install some-package installs that same package for Lua 5.2.

    If LuaRocks was installed via a package manager, multiple Lua versions may or may not be supported (e.g. the Debian/Ubuntu package is configured for Lua 5.1 only).