aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-02-15 18:45:18 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-02-15 18:45:18 -0300
commit8d0df029b0da53d049f3b02e5e83b21c6000a583 (patch)
treeda029510061670ef702bcdfc73a3b86cd35955e7
parent89daf1f1588189f0fedc0b050408d785729a6833 (diff)
downloadluarocks-8d0df029b0da53d049f3b02e5e83b21c6000a583.tar.gz
luarocks-8d0df029b0da53d049f3b02e5e83b21c6000a583.tar.bz2
luarocks-8d0df029b0da53d049f3b02e5e83b21c6000a583.zip
fix: avoid nil crash if config_files is not fully filled
I couldn't track down which scenarios cause this, but it has happened on Windows: See: https://github.com/lunarmodules/luasystem/pull/17 See: https://github.com/lunarmodules/luasystem/actions/runs/7907096563/job/21583369125?pr=17
-rw-r--r--src/luarocks/cmd/config.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua
index 6a73c7ff..0227b18d 100644
--- a/src/luarocks/cmd/config.lua
+++ b/src/luarocks/cmd/config.lua
@@ -280,7 +280,12 @@ function config_cmd.command(args)
280 return nil, "Current directory is not part of a project. You may want to run `luarocks init`." 280 return nil, "Current directory is not part of a project. You may want to run `luarocks init`."
281 end 281 end
282 282
283 local prefix = dir.dir_name(cfg.config_files[scope].file) 283 local location = cfg.config_files[scope]
284 if (not location) or (not location.file) then
285 return nil, "could not get config file location for " .. tostring(scope) .. " scope"
286 end
287
288 local prefix = dir.dir_name(location.file)
284 local ok, err = persist.save_default_lua_version(prefix, args.value) 289 local ok, err = persist.save_default_lua_version(prefix, args.value)
285 if not ok then 290 if not ok then
286 return nil, "could not set default Lua version: " .. err 291 return nil, "could not set default Lua version: " .. err