From ad22942108da4f0fd98cf1e24ec80f5e8c7cc7e4 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Thu, 6 Oct 2022 02:34:51 +0200 Subject: [PATCH] LuaDefaults: Look for defaults.lua in $PWD first As DataDir may not exist yet. Fix #9593 --- frontend/luadefaults.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/luadefaults.lua b/frontend/luadefaults.lua index 955ad3ec5..9dd386e8c 100644 --- a/frontend/luadefaults.lua +++ b/frontend/luadefaults.lua @@ -46,11 +46,14 @@ function LuaDefaults:open(path) -- The actual defaults file, on the other hand, is set in stone. -- We just have to deal with some platform shenanigans... - local defaults_path = DataStorage:getDataDir() .. "/defaults.lua" + -- NOTE: On most platforms, $PWD should be our "install" folder, so look there first, + -- as DataDir may point elsewhere, and that elsewhere may not exist yet ;). + local defaults_path = "defaults.lua" if isAndroid then defaults_path = android.dir .. "/defaults.lua" - elseif os.getenv("APPIMAGE") then - defaults_path = "defaults.lua" + elseif not util.fileExists(defaults_path) then + -- You probably have bigger problems than this if we didn't find it in the install folder, but, oh, well ;). + defaults_path = DataStorage:getDataDir() .. "/defaults.lua" end ok, stored = pcall(dofile, defaults_path) if ok and stored then