aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/cfg.lua26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index a02caaee..48623765 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -145,13 +145,28 @@ end
145cfg.variables = {} 145cfg.variables = {}
146cfg.rocks_trees = {} 146cfg.rocks_trees = {}
147 147
148-- The global environment in the config files;
149local env_for_config_file
150env_for_config_file = {
151 home = cfg.home,
152 lua_version = cfg.lua_version,
153 platform = util.make_shallow_copy(detected),
154 processor = proc,
155 os_getenv = os.getenv,
156 dump_env = function()
157 -- debug function, calling it from a config file will show all
158 -- available globals to that config file
159 print(util.show_table(env_for_config_file, "global environment"))
160 end,
161}
162
148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" 163sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua"
149do 164do
150 local err, errcode 165 local err, errcode
151 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 166 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file)
152 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file 167 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
153 sys_config_file = sys_config_dir.."/config.lua" 168 sys_config_file = sys_config_dir.."/config.lua"
154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 169 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, env_for_config_file)
155 end 170 end
156 if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error 171 if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error
157 io.stderr:write(err.."\n") 172 io.stderr:write(err.."\n")
@@ -159,13 +174,6 @@ do
159 end 174 end
160end 175end
161 176
162local env_for_config_file = {
163 home = cfg.home,
164 lua_version = cfg.lua_version,
165 platform = util.make_shallow_copy(detected),
166 processor = proc,
167}
168
169if not site_config.LUAROCKS_FORCE_CONFIG then 177if not site_config.LUAROCKS_FORCE_CONFIG then
170 178
171 local home_overrides, err, errcode 179 local home_overrides, err, errcode