Wrong cache directory path on linux
yztxwd opened this issue · 1 comments
Describe the bug
:SnipInfo
gave me the error
E5108: Error executing lua ...e/jmy5455/.local/share/nvim/lazy/sniprun/lua/sniprun.lua:281: attempt to index local 'file' (a nil value)
stack traceback:
...e/jmy5455/.local/share/nvim/lazy/sniprun/lua/sniprun.lua:281: in function 'lines_from'
...e/jmy5455/.local/share/nvim/lazy/sniprun/lua/sniprun.lua:326: in function 'info'
[string ":lua"]:1: in main chunk
To Reproduce
:SnipInfo
Expected behavior
Give me a table on compatibility
Environment:
- Neovim version [v0.9.1]
- LuaJIT 2.1.0-beta3
- Ubuntu 20.04
Additional context
I found out this is due to somehow the default_cache_dir
was set to a Macos one "/home/jmy5455/Library/Caches", after looking into the code. It seems like it's due to
if vim.fn.isdirectory(os.getenv("HOME").."/Library/Caches") then -- we're (probably) on MacOS
default_cache_dir = os.getenv("HOME").."/Library/Caches"
end
vim.fn.isdirectory(...)
returned 0
, then it's deemed as true, which caused the issue, i'm very new to lua so not sure if this is what it should behave like.
I fixed the issue by simply replace the condition with if (vim.fn.isdirectory(os.getenv("HOME").."/Library/Caches")~=0) then -- we're (probably) on MacOS
Now :SnipInfo
works well
Thanks!
Your suggestion will be applied in the next version (and will live in the dev branch in the meantime), I will close this issue when I merge it into the master branch.
It's a bit strange that you encountered this issue, I'm also on Linux (obviously no ~/Library/Caches) and I didn't have it. I hope no MacOS users will come screaming back because you broke their :SnipInfo