Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you install dependencies listed in Luarocks?

Tags:

lua

luarocks

I have the following luarocks:

package = "project-name"
version = "1.0-1"
source = {
   url = "..."
}
description = {
   summary = "etc"
   detailed = [[]],
   homepage = ""
}
dependencies = {
   "lua >= 5.1, < 5.2",
   "busted >= 2.0.rc12",
   "lua-requests >= 1.1",
   "json-lua >= 0.1",
   "lua-resty-dogstatsd >= 1.0.1"
}
build = {
    type = "builtin",
    modules = {
        ["project-name"] = "project/init.lua"
    }
}

How do I install the dependencies? Doing luarocks install says I'm missing arguments. Not sure what to do here.

like image 757
Kousha Avatar asked Mar 29 '19 19:03

Kousha


People also ask

How do I install LuaRocks modules?

Installing packages to the current directory is as simple as. luarocks install --tree lua_modules lpeg. This will install the package lpeg (and any dependencies if necessary) to the directory lua_modules in the current directory. Loading those modules is a bit more complicated.

Should I include require in my LuaRocks code?

Do not include require ("set_paths") in your code, scroll up to see why. Installing packages to the local tree, or the home directory, requires the --local flag to be passed to the luarocks install install command.

What is the LuaRocks command in Linux?

The luarocks command isn't actually required to use packages from the Luarocks website, but it does keep you from having to leave your text editor and venture onto the worldwide web [of potential distractions]. To install Luarocks, you first need to install Lua.

How do I run LuaRocks in WSL?

The Windows Linux Subsystem allows users to install the luarocks package. This will make the luarocks command available via a WSL shell. Use wsl luarocks for Windows shells. Rocks will only be available within WSL, not Windows.


2 Answers

To install a single dependency manually, you can run

luarocks install <dep-name>

You can append an optional version such as

luarocks install lua-resty-jwt 0.1.11-0

To install all dependencies listed in the Rockspec file,

luarocks install --only-deps <rockspec_file>

From the manual of luarocks install:

--only-deps Installs only the dependencies of the rock.

Alternatively, you can simply run

luarocks make

which will also install missing dependencies for you. However, do note that it may not be what you want, depending on your needs:

This command is useful as a tool for debugging rockspecs. To install rocks, you'll normally want to use the "install" and "build" commands. See the help on those for details.

NB: Use luarocks install with the --only-deps flag if you want to install only dependencies of the rockspec (see luarocks help install).

like image 58
z11i Avatar answered Oct 23 '22 20:10

z11i


luarocks build will install all dependencies listed in the rockspec. If you do luarocks init project_name first you'll get a local luarocks command that will install modules locally to the project. Have only tested this on windows. I assume other platforms behave similarly

like image 29
Kartik Avatar answered Oct 23 '22 19:10

Kartik