nvim-telekasten / telekasten.nvim

A Neovim (lua) plugin for working with a markdown zettelkasten / wiki and mixing it with a journal, based on telescope.nvim
MIT License
1.41k stars 90 forks source link

[BUG] path.lua:503: FileNotFoundError #151

Closed adrianocorrea closed 2 years ago

adrianocorrea commented 2 years ago

Please confirm

Describe the bug After installing Telekasten (with the required dependencies, including Plenary and Telescope) using either VimPlug or Packer on Windows 11 and WSL2, and executing :Telekasten new_note one gets the following error:

Telekasten.nvim: home folder \Users\MyUser\zettelkasten does not exist! Shall I create it? [y/N] yE5108: Error executing lua ...ocal\nvim-data\plugged\plenary.nvim/lua/plenary/path.lua:503: FileNotFoundError
stack traceback:
        [C]: in function 'error'
        ...ocal\nvim-data\plugged\plenary.nvim/lua/plenary/path.lua:503: in function 'mkdir'
        ...cal\nvim-data\plugged\telekasten.nvim/lua/telekasten.lua:245: in function 'check_dir_and_ask'
        ...cal\nvim-data\plugged\telekasten.nvim/lua/telekasten.lua:267: in function 'global_dir_check'
        ...cal\nvim-data\plugged\telekasten.nvim/lua/telekasten.lua:2099: in function 'selection'
        ...cal\nvim-data\plugged\telekasten.nvim/lua/telekasten.lua:3032: in function 'panel'

After manually creating the folder and sub-folders (e.g. daily, weekly, etc), one still gets the same error when making news notes.

:checkhealth shows no errors.

To Reproduce Steps to reproduce the behaviour:

  1. Start nvim
  2. Run :Telekasten new_note
  3. See prompt "Telekasten.nvim: home folder \User\MyUser\zettelkasten does not exist! Shall I create it? [y/N]"
  4. Press "y"
  5. See error

Expected behaviour The expected behaviour would be Telekasten creating the zettelkasten home folder.

Operating system (please complete the following information):

Rom1deTroyes commented 2 years ago

Wsl2 is a (Frankenstein) GNU/Linux VM, so it's strange to have \ in the paths...

Are you sure all you need (nvim & Co) are the wsl2 ones ? wsl2 can launch binaries from Windows too, and runs strange behaviors sometimes (get me 2 days to resolve a strange ipython version last year :-)

adrianocorrea commented 2 years ago

The error above is the output on Windows 11, running nvim-qt.exe. On WSL2, the error message is the following (which does not show the "\" in the paths):

Telekasten.nvim: home folder /home/myuser/zettelkasten does not exist! Shall I create it? [y/N] yE5108: Error executing lua ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:503: FileNotFoundError
stack traceback:
        [C]: in function 'error'
        ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:503: in function 'mkdir'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:245: in function 'check_dir_and_ask'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:267: in function 'global_dir_check'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:2099: in function 'selection'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:3032: in function 'panel'
        [string ":lua"]:1: in main chunk

However, it seems to be the same error.

About the binaries, they were installed with homebrew (including neovim), so they should not be substantially different from the ones running on most MacOS and some "standard" Linux distros.

Note: On MacOS, Telekasten works as expected.

lambtho12 commented 2 years ago

Hard to debug as I do not have windows myself. From the error stack, it seems that this is related to Plenary (mkdir crashes) and not Telekasten. My guess (no way to check it) is that nvim does not have enough permission to create that file. So maybe the path you setup as your home is not correct to begin with.

You said that you tried manually creating the folders and it was still resulting of the same error. This should not be possible. If TK finds the folders, it will not need to call mkdir in the first place. Are you sure you created them correctly and referred to them properly in TK?

adrianocorrea commented 2 years ago

The setup is correct and working both on Linux and macOS.

It seems that the CleanPath function is causing the bug. I have proposed a bug fix in #152.

mingyar commented 2 years ago

Hey guys! It looks that I getting the same issue, but I'm on MacOS here.

Steps to reproduce the behaviour:

Start nvim Run :Telekasten new_note See prompt "Telekasten.nvim: home folder \User\MyUser\zettelkasten does not exist! Shall I create it? [y/N]" Press "y" See error

Telekasten.nvim: home folder ~/zettelkasten does not exist! Shall I create it? [y/N] yE5108: Error executing lua ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:503: Fil
eNotFoundError
stack traceback:
        [C]: in function 'error'
        ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:503: in function 'mkdir'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:238: in function 'check_dir_and_ask'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:260: in function 'global_dir_check'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:2103: in function 'selection'
        ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:3072: in function 'panel'
        [string ":lua"]:1: in main chunk

I'm using LunarVim here and my plugin config look like this:

{
    "renerocksai/telekasten.nvim",
    require('telekasten').setup({
      home                        = '~/zettelkasten',
      dailies                     = '~/zettelkasten/daily',
      weeklies                    = '~/zettelkasten/weekly',
      templates                   = '~/zettelkasten/templates',
      extension                   = ".md",
      take_over_my_home           = true,
      follow_creates_nonexisting  = true,
      dailies_create_nonexisting  = true,
      weeklies_create_nonexisting = true,
      template_new_note           = '~/zettelkasten/templates/new_note.md',
      template_new_daily          = "~/zettelkasten/templates/daily.md",
      template_new_weekly         = "~/zettelkasten/templates/weekly.md",
    })

Thanks in advance!

renerocksai commented 2 years ago

Please, see the readme. Don't use backslashes.

From the readme:

if you must use Windows, it is preferable to use C:/Users/myname/zettelkasten instead of ~/zettelkasten

NEVER use C:\Users\myname style paths

Using vim.fn.expand("~/zettelkasten") should work now but mileage will vary with anything outside of finding and opening files

adrianocorrea commented 2 years ago

Hi @mingyar, Try setting the home variable outside the setup function. For example, you may do something like this in your init.lua:

local home = vim.fn.expand("~/zettelkasten")

require("telekasten").setup({
   home = home,
   dailies = home .. "/" .. "daily",
   -- ...
})

Let us know if it works.

mingyar commented 2 years ago

Thanks @renerocksai and @adrianocorrea!

It worked by doing:

local home = vim.fn.expand("~/zettelkasten")

{
   "renerocksai/telekasten.nvim",
    require('telekasten').setup({
         home                        = home,
         dailies                     = home .. '/daily',
         weeklies                    = home .. '/weekly',
         templates                   = home .. '/templates',
         extension                   = ".md",
         take_over_my_home           = true,
         follow_creates_nonexisting  = true,
         dailies_create_nonexisting  = true,
         weeklies_create_nonexisting = true,
         template_new_note           = home .. '/templates/new_note.md',
         template_new_daily          = home .. "/templates/daily.md",
         template_new_weekly         = home .. "/templates/weekly.md",
       })
  },