Kousha
Kousha

Reputation: 36189

How do you install dependencies listed in 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.

Upvotes: 10

Views: 6950

Answers (4)

z11i
z11i

Reputation: 1296

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).

Upvotes: 7

Kartik
Kartik

Reputation: 181

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

Upvotes: 3

Dan
Dan

Reputation: 385

As I understand, the question is although you install with that rockspec, it doesn’t install rocks declared in dependencies. Firstly could you do following command to check if above dependencies exist?

Command: luarocks list | grep [dependency_name]

For Example: luarocks list | grep json-lua

(luarocks list list all the rocks be installed)

Upvotes: 0

Rick
Rick

Reputation: 57

OK what's wrong with

luarocks install busted
luarocks install lua-requests
luarocks install json-lua
luarocks install lua-resty-dogstatsd

Upvotes: -7

Related Questions