5

I'm building a Lua library (an internal kong plugin actually), and this is the first time I'm using Lua - let alone writing production code with it.

I've made it a luarock. From what I can see, the rockspec lets me specify other libraries as dependencies. But there doesn't seem to be a notion of dev-dependencies as such. Like for example, libraries that I need for my tests, mocks etc... And I would rather not make them part of the actual dependencies list.

I've resorted to keeping my dev-dependencies in the dependencies list, but commenting them out before a git push. How is this normally solved on production Lua projects? What's the recommended way to manage these dependencies?

CodeMangler
  • 1,709
  • 1
  • 20
  • 22

1 Answers1

3

There is no standard Lua depedency management system, but you can try out either:

LuaRocks - contains a rather large number of Lua modules distributed as rocks. Once LuaRocks is installed, the installation is simple: luarocks install desired-package. On Linux/Unix/Mac, this will install into /usr/local/{share,lib}/lua/5.1, where the Lua interpreter looks for modules.

LuaDist - designed to create an independent standalone directory with Lua and modules (a dist). Everything in LuaDist is CMake-based, which means that it can be easily compiled using any compiler/IDE supported by CMake. LuaDist also has an extensive repository which contains Lua modules and also many C dependencies/libraries, which allows to create a truly independent Lua "distribution". Installation is the same as with LuaRocks - luadist install desired-package.

Personally, I like LuaRocks more.

Kamila Szewczyk
  • 1,874
  • 1
  • 16
  • 33
  • Didn't know about LuaDist. Will check it out. But my primary issue is that LuaRocks itself doesn't have a notion of dev dependencies. Does LuaDist have support for something like that? – CodeMangler Aug 22 '18 at 06:43
  • Luarocks supports only depedencies, and now too iirc you would need shellscript installing depedencies. This way you have more control over them. – Kamila Szewczyk Aug 22 '18 at 06:49
  • Like when --production will be passed, don't install some of them – Kamila Szewczyk Aug 22 '18 at 06:50
  • Currently, I can do `luarocks install` which installs all dependencies for the current rock. This is fine for production - i.e. once I package and distribute the rock. But during development, the rock would depend on additional things - like test and mock libraries - which should not be part of the production code. I was hoping the `rockspec` itself would have some support for it - similar to `Gemfile` in the Ruby world, or what `package.json` supports in the NodeJS world. But if having an explicit script to install dependencies is the only way to go, then guess that'll have to do. – CodeMangler Aug 22 '18 at 09:08
  • @CodeMangler then, could you accept my answer, if it helped you? – Kamila Szewczyk Aug 22 '18 at 10:09
  • I used LuaRocks as Kong is using it. I even use docker with Kong base image to make an image with my plug-ins. It became quite clean. – Navid Nabavi Aug 26 '18 at 06:55