Skip to content

datafile fails to locate assets installed by LuaRocks all-in-one binaries #28

@luau-project

Description

@luau-project

Related issues

Description

At the moment (datafile 0.11-1 hosted on LuaRocks website), the datafile library fails to locate assets when it was installed by all-in-one LuaRocks binaries.

Note

By LuaRocks all-in-one binary, I mean a binary produced by https://github.com/luarocks/luarocks/blob/main/binary/all_in_one.

Details

During my research to solve the related issue above, I got to the conclusion that the following excerpt

local cfg
ok, cfg = pcall(require, "luarocks.cfg") -- LuaRocks 2
if not ok then
_, cfg = pcall(require, "luarocks.core.cfg") -- LuaRocks 3
end
if cfg then
if not cfg.lua_extension then -- cfg not initialized
if cfg.init then
local cfg_ok, err = cfg.init()
if cfg_ok and cfg.init_package_paths then
cfg.init_package_paths()
end
end
end
end
if not (cfg and cfg.lua_extension) then
-- cfg still not initialized, bail out!
return {}
end

will always return an empty table, because all the sources luarocks.*.lua will not be installed for the all-in-one binaries (reason: these sources are bundled inside the LuaRocks binary, they are not available on disk for the lua interpreter).

Reproduction

I wrapped a small example (https://github.com/luau-project/ci-tests/tree/datafile-issue) together with a GitHub workflow. Inspect the runs (https://github.com/luau-project/ci-tests/actions/runs/23016344708) comparing all-in-one and from-source jobs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions