From e886e39e592e89f316536a6f070365a9d88901c9 Mon Sep 17 00:00:00 2001 From: EdenEast Date: Tue, 5 Sep 2023 08:49:09 -0400 Subject: [PATCH] fix(compiler): add file permission error (#368) --- lua/nightfox/lib/compiler.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lua/nightfox/lib/compiler.lua b/lua/nightfox/lib/compiler.lua index e1be3414..8b050c2a 100644 --- a/lua/nightfox/lib/compiler.lua +++ b/lua/nightfox/lib/compiler.lua @@ -67,14 +67,27 @@ vim.o.background = "%s" local output_path, output_file = config.get_compiled_info(opts) util.ensure_dir(output_path) - local file + local file, err if vim.g.nightfox_debug then file = io.open(output_file .. ".lua", "wb") file:write(table.concat(lines, "\n")) file:close() end - file = io.open(output_file, "wb") + file, err = io.open(output_file, "wb") + if not file then + require("nightfox.lib.log").error(fmt( + [[Couldn't open %s: %s. + +Check that %s is accessible for the current user. +You could try deleting %s to reset permissions]], + output_file, + err, + output_file, + output_path + )) + return + end local f = loadstring(table.concat(lines, "\n"), "=") if not f then