lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 6 July 2018 at 14:57, François Perrad <francois.perrad@gadz.org> wrote:
>
>
> 2018-07-05 0:36 GMT+02:00 Hisham <h@hisham.hm>:
>>
>> Hello list,
>>
>> I am extremely happy to announce LuaRocks 3.0.0beta1, the
>> almost-finished package for the new major release of LuaRocks, the Lua
>> package manager.
>>
>>
>
> With Buildroot (embedded linux), I run `configure --prefix=my_path`.
> The installed `luarocks` script is properly patched with :
>     package.loaded['luarocks.core.hardcoded'] = { SYSCONFDIR =
> [[my_path/etc/luarocks]] }
>
> cfg.init is called a first time by loaded.lua:19, SYSCONFDIR is present in
> luarocks.core.hardcoded,
> and the config file (my_path/etc/luarocks/config-5.3.lua) is successfully
> loaded.
>
> At the end of loader.lua, package.loaded['luarocks.core.hardcoded'] is
> removed (with all others luarocks.*).
>
> cfg.init is called a second time by cmd.lua:364, but now the config file is
> not found.

Thank you for digging through this!

> A workaround is to set the environment variable LUAROCKS_SYSCONFDIR with
> my_path/etc/luarocks.
> With this workaround, rocks are successfully built (including
> cross-compilation).
>
> But I think that the condition in loader.lua:267 must be inverted.

The problem was not in loader.lua:267, but that bin/luarocks needs a
`require("luarocks.core.cfg")` before `require("luarocks.loader")`.
The `is_clean` variable is there to detect if the environment was
"clean" before calling luarocks.loader (i.e. no LuaRocks modules
around, as in a third-party application that uses luarocks.loader).
So, if the environment "is clean" at the beginning, when
luarocks.loader is done setting up, it cleans all other luarocks
references. The problem was that, since the require was removed from
bin/luarocks, luarocks.loader thought it was running from a "clean"
environment (and not from bin/luarocks).

Still, this exposes a deeper problem: even with that fix, if
luarocks.loader is used standalone from an application, it won't find
the sysconfig file. I think loader.lua will have to be patched upon
installation to get a hardcoded.SYSCONFDIR the same way that
bin/luarocks currently is. We moved the various configurations that
were in the site_config module into the LuaRocks config file proper,
but we need at least one hardcoded entry in order to find the config
file itself.

Once again, thank you! I am going to provide a fix and release a beta2 package.

I'm still a bit puzzled by Matthew's error message, though. Not
finding a config file should produce a default configuration, but not
crash — I was able to reproduce the problem you described, but not his
crash.

-- Hisham