From 9943217b68457fb7ffdeffcf0df9af2861a1e07a Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 7 Sep 2018 01:11:18 +0300 Subject: cfg: allow an empty rocks_trees in a config-5.x.lua file This is so a project uses only the auto-inserted project tree --- src/luarocks/core/cfg.lua | 5 ++--- src/luarocks/loader.lua | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 7a764160..bab6bd06 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua @@ -584,8 +584,6 @@ function cfg.init(lua_data, project_dir, warning) LUA_LIBDIR = lua_libdir, } - cfg.rocks_trees = {} - cfg.init = init ---------------------------------------- @@ -704,7 +702,8 @@ function cfg.init(lua_data, project_dir, warning) cfg.variables.LUA_DIR = lua_data.lua_dir or cfg.variables.LUA_DIR or lua_dir -- Build a default list of rocks trees if not given - if not next(cfg.rocks_trees) then + if cfg.rocks_trees == nil then + cfg.rocks_trees = {} if cfg.home_tree then table.insert(cfg.rocks_trees, { name = "user", root = cfg.home_tree } ) end diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index 4df55a04..780a0371 100644 --- a/src/luarocks/loader.lua +++ b/src/luarocks/loader.lua @@ -60,7 +60,7 @@ loader.rocks_trees = nil function loader.load_rocks_trees() local any_ok = false local trees = {} - for _, tree in ipairs(cfg.rocks_trees) do + for _, tree in ipairs(cfg.rocks_trees or {}) do local manifest, err = manif.fast_load_local_manifest(path.rocks_dir(tree)) if manifest then any_ok = true -- cgit v1.2.3-55-g6feb