From 2b85f108a6153a9c37d629fc06f891a16e4ff9b7 Mon Sep 17 00:00:00 2001 From: apgrc <43510217+apgrc@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:36:57 -0600 Subject: [PATCH 1/2] Fallback temp files to OS temp directory --- lua/null-ls/loop.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/null-ls/loop.lua b/lua/null-ls/loop.lua index d716a5a8..62e1245e 100644 --- a/lua/null-ls/loop.lua +++ b/lua/null-ls/loop.lua @@ -231,7 +231,20 @@ M.temp_file = function(content, bufname, dirname) local filename = string.format(".null-ls_%d_%s", math.random(100000, 999999), base_name) ---@type string? - local temp_path = u.path.join(dirname, filename) + local temp_path + + if u.path.exists(dirname) then + temp_path = u.path.join(dirname, filename) + else + local temp_dir = + -- windows + os.getenv("TEMP") or + os.getenv("TMP") or + -- linux / mac + os.getenv("TMPDIR") or + "/tmp" + temp_path = u.path.join(temp_dir, filename) + end local fd, err = uv.fs_open(temp_path --[[@as string]], "w", 384) if not fd then From 9e0f6b7704884d490f57f2126586f87b31341d67 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:38:29 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lua/null-ls/loop.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/null-ls/loop.lua b/lua/null-ls/loop.lua index 62e1245e..7b34c7fd 100644 --- a/lua/null-ls/loop.lua +++ b/lua/null-ls/loop.lua @@ -238,11 +238,11 @@ M.temp_file = function(content, bufname, dirname) else local temp_dir = -- windows - os.getenv("TEMP") or - os.getenv("TMP") or + os.getenv("TEMP") + or os.getenv("TMP") -- linux / mac - os.getenv("TMPDIR") or - "/tmp" + or os.getenv("TMPDIR") + or "/tmp" temp_path = u.path.join(temp_dir, filename) end