Search code examples
lualuarocks

Why have I errors when installing from Luarocks?


I am the developer of this small library: https://github.com/martin-damien/babel and I have a problem with Luarocks releases.

From source

When I install from source with Luarocks I have no problem:

$ luarocks make --local rockspecs/babel-1.2-2.rockspec

From internet

But when deployed (using: tag master, add new rockspec release and publish to Luarocks), I can't install using

$ luarocks install --local babel

Because I encounter the following error:

Installing https://luarocks.org/babel-1.2-2.src.rock... Using https://luarocks.org/babel-1.2-2.src.rock... switching to 'build' > mode stat: malsukcesis eltrovi statinformon pri «locales/zh-HK.lua»: No such > file or directory

Error: Build error: Failed installing locales/zh-HK.lua in /home/damien/.luarocks/lib/luarocks/rocks/babel/1.2-2/lua/locales/zh-HK.lua: locales/zh-HK.lua: No such file or directory

As you can see in https://github.com/martin-damien/babel/issues/14 the error occure on different files (but until now, only with locale files, not with the babel.lua file).

I have no idea why it randomly crash like this, so if someone know why or have an idea from where it could come from...

Thanks in advance,

Damien


Solution

  • The location of the files in the build.modules table is (from the docs on the rockspec format):

    relative to source.dir

    Where source.dir is

    source.dir (string) - the name of the directory created when the source archive is unpacked. Can be omitted if it can be inferred from the source.file field. Example: "luasocket-2.0.1"

    and source.file is

    source.file (string) - the filename of the source archive. Can be omitted if it can be inferred from the source.url field. Example: "luasocket-2.0.1.tar.gz"

    You don't specify source.dir or source.file in your rockspec but you do set source.url (because you have to).

    So you have source.url = https://github.com/martin-damien/babel/archive/v1.2-2.zip which (presumably) ends up with source.file = v1.2-2.zip and then source.dir = v1.2-2 but your zip file extracts into a babel-1.2 so luarocks can't find your source files. (The screenshot in the linked issue seems to indicate that luarocks uses source.file = v1.2.zip and the archive extracts to babel-1.2 but I'm not sure how that's possible.)

    Add dir = "babel-1.2" to your rockspec's source table an I expect it will work.