Some impressions about LuaRocks

I've gone off against “control panels [1]” (and “package managers [2]”) a few times so it's odd that I find myself playing around with LuaRocks [3], a package manager for installing Lua-based software (Perl has CPAN (Comprehensive Perl Archive Network) [4], Ruby has RubyGems [5], so it's not uncommon for package management to exist for languages).

So far, it hasn't been that horrible. One neat aspect of LuaRocks is that the specification for a “rock [6]” can exist outside the source code that comprises a “rock.” For instance, the following “rockspec [7]:”

>
```
package = "OrgConman"
version = "1.0.0-1"
source =
{
url = "git://github.com/spc476/lua-conmanorg.git",
branch = "master",
}
description =
{
homepage = "https://github.com/spc476/lua-conmanorg",
maintainer = "Sean Conner",
license = "LGPL",
summary = "Useful modules. A lot of useful modules",
detailed = [[
A lot of useful routines to manipulate tables. Yes, I should write
more text here. But I'm still playing aorund with this stuff.
]],
}
supported_platforms =
{
"linux",
"macosx",
"freebsd",
"unix"
}
dependencies =
{
"lua ~> 5.1"
}
external_dependencies =
{
TCC = { header = "libtcc.h" },
OPENSSH = { library = "crypto" },
MAGIC = { header = "magic.h" },
RT = { library = "rt" },
}
build =
{
type = "make",
copy_directories = {},
variables =
{
CC = "$(CC) -std=c99",
CFLAGS = "$(CFLAGS)",
LFLAGS = "$(LIBFLAG)",
LUALUA = "$(LUADIR)",
LUALIB = "$(LIBDIR)",
},
}
```

can be used, as is, to install the package, even though no existing “rock” exists, nor has it been published [8] anywhere. All it takes is saving it in a file called orgconman-1.0.0-1.rockspec, and running luarocks build orgconman-1.0.0-1.rockspec—it will then download the code from github [9], build it and install it (assuming you meet the dependencies listed).

And once published, it will be a simple luarocks install orgconman to install the code (this will check the “rock servers” listed in the configuration file for the named “rock”, download the “rockspec” and then build and install it).

Even nicer, you can specify different locations to install the resulting “rocks” beside the default /usr/local/lib/lua/ (such locations can be specified in the configuration file, or on the command line).

[DELETED-So far, the only problematic aspect of LuaRocks I've encountered is actually making a “rock.” luarocks pack rockspec doesn't quite work out of the box:

>
```
[spc]lucy:/tmp>luarocks pack orgconman-1.0.0-1.rockspec
Initialized empty Git repository in /tmp/luarocks_orgconman-1.0.0-1-7168/lua-conmanorg/.git/
remote: Counting objects: 41, done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 41 (delta 11), reused 11 (delta 2)
Receiving objects: 100% (41/41), 60.55 KiB, done.
Resolving deltas: 100% (11/11), done.
sh: line 0: cd: lua-conmanorg: No such file or directory
Packed: /tmp/orgconman-1.0.0-1.src.rock
```

It seems like it's not switching into the temporary build directory when trying to make the “rock.” I can work around it (by checking out the code at the same level as the “rockspec”), but I still find that bug annoying.

-DELETED]

Another issue—there is no easy way to specify the language level (C89 or C99) in a platform independent way. Here, I have to assume the given platforms I do support use gcc, but not all platforms I currently use Lua on have gcc (Solaris [10] comes to mind). Again, I'm working around the issue, but I feel it is something that should be addressed somehow.

This is also having me rethink how I develop the modules I have developed. Right now, they all exist in a single repository, but all the modules are mostly independent. But there isn't a simple way to checkout specific files using git, so I may have to make sepearate repositories for each module (so far, 22 existing modules, two additional ones I could add).

Update on Tuesday, February 25^th, 2013

The issue wasn't with LuaRocks [11] …

[1] https://www.google.com/search?q=control+panels+site%3Aboston.conman.org

[2] https://www.google.com/search?q=package+manager+site%3Aboston.conman.org

[3] http://www.luarocks.org/

[4] http://www.cpan.org/

[5] http://rubygems.org/

[6] http://www.luarocks.org/en/Types_of_rocks

[7] http://www.luarocks.org/en/Rockspec_format

[8] http://luarocks.org/repositories/rocks/

[9] https://github.com/spc476/lua-conmanorg

[10] http://en.wikipedia.org/wiki/Solaris_(operating_system)

[11] /boston/2013/02/26.1

Gemini Mention this post

Contact the author