How do you install dependencies listed in Luarocks?
Asked Answered
D

4

10

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.

Diesel answered 29/3, 2019 at 19:8 Comment(2)
luarocks install alone won't do anyhting. you have to provide a module nameHeady
@Heady yes I've said that, and hence the question :PDiesel
P
7

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

Pryce answered 19/6, 2020 at 4:3 Comment(0)
G
3

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

Glue answered 26/12, 2019 at 1:33 Comment(0)
E
0

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)

Exfoliation answered 22/4, 2019 at 5:31 Comment(0)
G
-6

OK what's wrong with

luarocks install busted
luarocks install lua-requests
luarocks install json-lua
luarocks install lua-resty-dogstatsd
Gillette answered 30/3, 2019 at 0:40 Comment(4)
When you use npm or python do you use npm install package1 package2 package3 or pip install package1 package2 package3 or do you keep a dependency file like package.json and requirement.txt and then just run an installation on all of them?Diesel
Why are you bringing python to a lua discussion? If you're not getting the answer you want maybe it's because the question is poorly formed. You asked how to install these dependencies with the "luarocks install" command-line and it was explained to you.Gillette
The whole point of dependency management is that I don't have to manually run install package1 && install package2 && install package3 and rather have some kind of a configuration where dependencies are defined in it, and I just say install and it will install all those dependencies for me. Exactly how to say Node, Python, Java, Go, PHP and all other languages do this.Diesel
@Gillette the question is not poorly formed. The OP is trying to understand how to install ALL dependencies listed in a file with a single command, without having to specify them by hand. And it seems luarocks doesn't support that (?). If that's true, I'm just like OP curious why not.Barren

© 2022 - 2024 — McMap. All rights reserved.