From bc3ac2174e0404b13afee9114bd38e4f3bfb476b Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 24 Oct 2015 23:22:39 -0400 Subject: If LUAROCKS_CONFIGURE is given and is invalid, do not silently switch to a default path. Fail instead (and report that when the user checks the configuration.) --- src/luarocks/cfg.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index a4f60f55..ec9a9829 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -228,17 +228,26 @@ end if not site_config.LUAROCKS_FORCE_CONFIG then home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" - local list = { - os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), - home_config_file_default, - home_config_dir.."/config.lua", - } - -- first entry might be a silent nil, check and remove if so - if not list[1] then table.remove(list, 1) end - - home_config_file = load_config_file(list) - home_config_ok = (home_config_file ~= nil) + local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix + local config_env_value = os.getenv(config_env_var) + if not config_env_value then + config_env_var = "LUAROCKS_CONFIG" + config_env_value = os.getenv(config_env_var) + end + if config_env_value then + home_config_ok = load_config_file({ config_env_value }) + if not home_config_ok then + io.stderr:write("Warning: could not load file "..config_env_value.." given in environment variable "..config_env_var) + end + home_config_file = config_env_var + else + home_config_file = load_config_file({ + home_config_file_default, + home_config_dir.."/config.lua", + }) + home_config_ok = (home_config_file ~= nil) + end end -- cgit v1.2.3-55-g6feb