From 660bd8815ef8da029fa0058f76ac7fa2ca8f9ec7 Mon Sep 17 00:00:00 2001 From: Cory Shaw Date: Mon, 27 Jun 2022 16:05:34 -0400 Subject: [PATCH] Fix sudo error on macOS (#68) When using sudo a separate environment is used unless specifying sudo -E. This fixes the error of path being nil when using neovim in sudo --- lua/presence/init.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/presence/init.lua b/lua/presence/init.lua index 966fded..ff7db70 100644 --- a/lua/presence/init.lua +++ b/lua/presence/init.lua @@ -365,9 +365,12 @@ function Presence:get_discord_socket_path() elseif self.os.name == "macos" then -- Use $TMPDIR for macOS local path = os.getenv("TMPDIR") - sock_path = path:match("/$") - and path..sock_name - or path.."/"..sock_name + + if path then + sock_path = path:match("/$") + and path..sock_name + or path.."/"..sock_name + end elseif self.os.name == "linux" then -- Check various temp directory environment variables local env_vars = {