diff options
-rw-r--r-- | src/luarocks/cfg.lua | 26 |
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 | |||
145 | cfg.variables = {} | 145 | cfg.variables = {} |
146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
147 | 147 | ||
148 | -- The global environment in the config files; | ||
149 | local env_for_config_file | ||
150 | env_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 | |||
148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 163 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
149 | do | 164 | do |
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 |
160 | end | 175 | end |
161 | 176 | ||
162 | local 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 | |||
169 | if not site_config.LUAROCKS_FORCE_CONFIG then | 177 | if not site_config.LUAROCKS_FORCE_CONFIG then |
170 | 178 | ||
171 | local home_overrides, err, errcode | 179 | local home_overrides, err, errcode |