nvim-tree.lua
                                
                                 nvim-tree.lua copied to clipboard
                                
                                    nvim-tree.lua copied to clipboard
                            
                            
                            
                        Could not start the fs_event watchter for path
Description
When I toggle NvimTree first time after opening the editor it takes a couple of seconds and I get this error:

Also, opening folders in the tree for the first time is quite slow (like half a second at least), after the first time they open seamlessly.
Neovim version
NVIM v0.7.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Operating system and version
Windows 10 Pro N
nvim-tree version
1685484
Minimal config
I just have `require 'nvim-tree'.setup()`.
Steps to reproduce
- Open neovim
- Do :NvimTreeToggle
Expected behavior
No response
Actual behavior
No response
Also, opening folders in the tree for the first time is quite slow (like half a second at least), after the first time they open seamlessly.
Is that for a specific directory? How many files / directories? git repos? git submodules? symlinks?
I'm guessing that you are using powershell, from the \ in the path. Unfortunately we can't offer much support for windows, as we don't have expertise in or access to a windows environment.
Please:
- enable diagnostic logging for git, profile and watcher
- open vim / nvim-tree in a "small" directory that behaves well and collect logs
- open in the problem directory and collect logs
- attach the output of find .for the problem directory
Well apparently everything happens here:
  self._fs_event, _, name = uv.new_fs_event()
  if not self._fs_event then
    self._fs_event = nil
    utils.notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self._path, name))
    return false
  end
So I assume it might actually be neovim's fault.
I'm not using powershell, I'm using neovide on windows.
Here are the logs and a gif for a repo wih 6 files:
[2022-08-06 10:39:30] [profile] START git toplevel F:\prv\dev\projects\oxocarbon-lua.nvim
[2022-08-06 10:39:30] [git] git -C "F:\prv\dev\projects\oxocarbon-lua.nvim" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:39:31] [profile] END   git toplevel F:\prv\dev\projects\oxocarbon-lua.nvim  718ms
[2022-08-06 10:39:31] [profile] START git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:39:31] [git] git -C Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 config --type=bool status.showUntrackedFiles
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:39:32] [profile] END   git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
  598ms
[2022-08-06 10:39:32] [profile] START git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 10:39:32] [git] running job with timeout 400ms
[2022-08-06 10:39:32] [git] git --no-optional-locks status --porcelain=v1 --ignored=matching -u
[2022-08-06 10:39:32] [profile] END   git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil  402ms
[2022-08-06 10:39:32] [git] job timed out  Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 10:39:32] [profile] START draw
[2022-08-06 10:39:32] [profile] END   draw  1ms
[2022-08-06 10:39:32] [profile] START draw
[2022-08-06 10:39:32] [profile] END   draw  2ms

Here are the logs and a gif for a small directory but without a repo:
[2022-08-06 10:44:21] [profile] START git toplevel F:\prv\dev\projects\ragdoll
[2022-08-06 10:44:21] [git] git -C "F:\prv\dev\projects\ragdoll" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:44:21] [profile] END   git toplevel F:\prv\dev\projects\ragdoll  616ms
[2022-08-06 10:44:21] [profile] START git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:44:21] [git] git -C Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 config --type=bool status.showUntrackedFiles
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:44:22] [profile] END   git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
  618ms
[2022-08-06 10:44:22] [profile] START git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 10:44:22] [git] running job with timeout 400ms
[2022-08-06 10:44:22] [git] git --no-optional-locks status --porcelain=v1 --ignored=matching -u
[2022-08-06 10:44:22] [profile] END   git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil  403ms
[2022-08-06 10:44:22] [git] job timed out  Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 10:44:22] [profile] START draw
[2022-08-06 10:44:22] [profile] END   draw  2ms
[2022-08-06 10:44:22] [profile] START draw
[2022-08-06 10:44:22] [profile] END   draw  1ms
[2022-08-06 10:44:24] [profile] START git toplevel F:\prv\dev\projects\ragdoll\what
[2022-08-06 10:44:24] [git] git -C "F:\prv\dev\projects\ragdoll\what" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:44:25] [profile] END   git toplevel F:\prv\dev\projects\ragdoll\what  625ms
[2022-08-06 10:44:25] [profile] START draw
[2022-08-06 10:44:25] [profile] END   draw  2ms
[2022-08-06 10:44:26] [profile] START git toplevel F:\prv\dev\projects\ragdoll\aa
[2022-08-06 10:44:26] [git] git -C "F:\prv\dev\projects\ragdoll\aa" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 10:44:26] [profile] END   git toplevel F:\prv\dev\projects\ragdoll\aa  610ms
[2022-08-06 10:44:26] [profile] START draw
[2022-08-06 10:44:26] [profile] END   draw  1ms
[2022-08-06 10:44:28] [profile] START draw
[2022-08-06 10:44:28] [profile] END   draw  1ms

Here's the same thing for a bigger github repository. What's very weird is that it sometimes opens and works seamlessly and sometimes it works slowish like the two examples above.
The first log and gif is when it works seamlessly, the second log is when it works slow.
[2022-08-06 10:48:45] [profile] START git toplevel F:\prv\dev\forks\rigc-lang
[2022-08-06 10:48:45] [git] git -C "F:\prv\dev\forks\rigc-lang" rev-parse --show-toplevel
[2022-08-06 10:48:45] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang  0ms
[2022-08-06 10:48:45] [profile] START draw
[2022-08-06 10:48:45] [profile] END   draw  3ms
[2022-08-06 10:48:45] [profile] START draw
[2022-08-06 10:48:45] [profile] END   draw  2ms
[2022-08-06 10:48:49] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\examples
[2022-08-06 10:48:49] [git] git -C "F:\prv\dev\forks\rigc-lang\examples" rev-parse --show-toplevel
[2022-08-06 10:48:49] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\examples  1ms
[2022-08-06 10:48:49] [profile] START draw
[2022-08-06 10:48:49] [profile] END   draw  3ms
[2022-08-06 10:48:50] [profile] START draw
[2022-08-06 10:48:50] [profile] END   draw  2ms
[2022-08-06 10:48:51] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\bin
[2022-08-06 10:48:51] [git] git -C "F:\prv\dev\forks\rigc-lang\bin" rev-parse --show-toplevel
[2022-08-06 10:48:51] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\bin  0ms
[2022-08-06 10:48:51] [profile] START draw
[2022-08-06 10:48:51] [profile] END   draw  2ms
[2022-08-06 10:48:51] [profile] START draw
[2022-08-06 10:48:51] [profile] END   draw  2ms
[2022-08-06 10:48:52] [profile] START draw
[2022-08-06 10:48:52] [profile] END   draw  6ms
[2022-08-06 10:48:52] [profile] START draw
[2022-08-06 10:48:52] [profile] END   draw  2ms
[2022-08-06 10:48:53] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser
[2022-08-06 10:48:53] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser" rev-parse --show-toplevel
[2022-08-06 10:48:53] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser  0ms
[2022-08-06 10:48:53] [profile] START draw
[2022-08-06 10:48:53] [profile] END   draw  2ms
[2022-08-06 10:48:53] [profile] START draw
[2022-08-06 10:48:53] [profile] END   draw  2ms
[2022-08-06 10:48:54] [profile] START draw
[2022-08-06 10:48:54] [profile] END   draw  3ms
[2022-08-06 10:48:54] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include
[2022-08-06 10:48:54] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include" rev-parse --show-toplevel
[2022-08-06 10:48:54] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include  0ms
[2022-08-06 10:48:54] [profile] START draw
[2022-08-06 10:48:54] [profile] END   draw  2ms
[2022-08-06 10:48:54] [profile] START draw
[2022-08-06 10:48:54] [profile] END   draw  3ms
[2022-08-06 10:48:55] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\src
[2022-08-06 10:48:55] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\src" rev-parse --show-toplevel
[2022-08-06 10:48:55] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\src  0ms
[2022-08-06 10:48:55] [profile] START draw
[2022-08-06 10:48:55] [profile] END   draw  4ms
[2022-08-06 10:48:56] [profile] START draw
[2022-08-06 10:48:56] [profile] END   draw  2ms
[2022-08-06 10:48:57] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser
[2022-08-06 10:48:57] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser" rev-parse --show-toplevel
[2022-08-06 10:48:57] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser  0ms
[2022-08-06 10:48:57] [profile] START draw
[2022-08-06 10:48:57] [profile] END   draw  2ms
[2022-08-06 10:48:57] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar
[2022-08-06 10:48:57] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar" rev-parse --show-toplevel
[2022-08-06 10:48:57] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar  1ms
[2022-08-06 10:48:57] [profile] START draw
[2022-08-06 10:48:57] [profile] END   draw  7ms

[2022-08-06 11:16:26] [profile] START git toplevel F:\prv\dev\forks\rigc-lang
[2022-08-06 11:16:26] [git] git -C "F:\prv\dev\forks\rigc-lang" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:26] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang  617ms
[2022-08-06 11:16:26] [profile] START git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:26] [git] git -C Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 config --type=bool status.showUntrackedFiles
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:27] [profile] END   git untracked Error: 
  ├Ś The system cannot find the file specified. (os error 2)
  608ms
[2022-08-06 11:16:27] [profile] START git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 11:16:27] [git] running job with timeout 400ms
[2022-08-06 11:16:27] [git] git --no-optional-locks status --porcelain=v1 --ignored=matching -u
[2022-08-06 11:16:27] [profile] END   git job Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil  407ms
[2022-08-06 11:16:27] [git] job timed out  Error: 
  ├Ś The system cannot find the file specified. (os error 2)
 nil
[2022-08-06 11:16:27] [profile] START draw
[2022-08-06 11:16:27] [profile] END   draw  2ms
[2022-08-06 11:16:27] [profile] START draw
[2022-08-06 11:16:27] [profile] END   draw  2ms
[2022-08-06 11:16:31] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser
[2022-08-06 11:16:31] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:32] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser  618ms
[2022-08-06 11:16:32] [profile] START draw
[2022-08-06 11:16:32] [profile] END   draw  2ms
[2022-08-06 11:16:33] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include
[2022-08-06 11:16:33] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:34] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include  619ms
[2022-08-06 11:16:34] [profile] START draw
[2022-08-06 11:16:34] [profile] END   draw  2ms
[2022-08-06 11:16:34] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser
[2022-08-06 11:16:34] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:35] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser  615ms
[2022-08-06 11:16:35] [profile] START draw
[2022-08-06 11:16:35] [profile] END   draw  2ms
[2022-08-06 11:16:35] [profile] START git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar
[2022-08-06 11:16:35] [git] git -C "F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar" rev-parse --show-toplevel
Error: 
  ├Ś The system cannot find the file specified. (os error 2)
[2022-08-06 11:16:36] [profile] END   git toplevel F:\prv\dev\forks\rigc-lang\Parser\include\RigCParser\Grammar  619ms
[2022-08-06 11:16:36] [profile] START draw
[2022-08-06 11:16:36] [profile] END   draw  4ms
So when I look at the logs it looks like it's a git's issue? But also why does nvim-tree try to use git if I'm no in a repo?
After trying it for a little bit more it seems like the issues isn't only with git repos, big or small. It just sometimes happens and sometimes it doesn't...
But also why does nvim-tree try to use git if I'm no in a repo?
 rev-parse --show-toplevel is actually nvim-tree trying to determine whether it is in a git repo.
- [x] get_toplevelis not detecting the error in this case; fix: https://github.com/kyazdani42/nvim-tree.lua/commit/ff6e7966f39a897ac4d1358f4d022cfecdc88ff1
That's probably why we're hitting the watcher error: it's trying to watch that incorrect .git directory. I'm not seeing any file watcher errors, so I assume the problems are all git related.
Why is git -C "F:\prv\dev\projects\oxocarbon-lua.nvim" rev-parse --show-toplevel failing?
It's a problem with the shell: git operations are an external git command which is implicitly inside $SHELL or &shell. What is your shell? Try running that git command in it.
You could try changing your shell to a known good one i.e. bash or zsh
RE neovide I am afraid you are on your own. The above fix will stop the errors, however git will not be functional.
Please try running nvim in another way: I know of cygwin (msys2?), WSL or powershell.
If it is a neovide specific problem, we will accept a PR to fix it providing all the fix is behind the appropriate feature flag. I imagine it would be something like vim.fn.has "neovide".
@alex-courtis It doesn't display the error now which is nice, but I know what's the issue now.
It's not an issue regarding neovide it's an issue regarding my shell, which handles \ in strings "" as escape characters.

I think a general fix to that would be just escaping the strings doubly, so F:\prv\dev\projects would become F:\\prv\\dev\\projects. Cmd, powershell, git and a few other tools I've tested seem to handle doubly escaped strings properly.
I could file a PR but idk if this wouldn't break anything else.
I could file a PR but idk if this wouldn't break anything else.
nvim-tree supports many operating systems via vim.fn.has features:
- unix
- mac, macunix
- win32, win32unix (covers powershell, msys2 and WSL) see #1290
Any OS specific code is guarded by vim.fn.has feature flags. We are happy to add more OS specific code providing it is feature checked. In this case, we would need to use a neovide specific feature, so as not to break other windows users.
I did do a quick test of neovide on linux and there were no git issues.
For all operating systems, the git directory is escaped via vim.fn.shellescape which functions correctly. We should not need to second-guess this.
Please raise a neovide issue: vim.fn.shellescape is not functioning correctly.
@alex-courtis Well, once again, I don't think it's neovide's issue. Neovide only does it's rendering afaict. I did a test on windows on
- neovide
- nvim-qt
- nvim in terminal

And all of them escape correctly. So it's again either a problem with my shell, or a problem somewhere in nvim-tree.
Honestly I'm down to look into it, debug it a little bit more on my machine and come back with some feedback, but surely not today and probably not tomorrow.
One thing I noticed right now is that if I have my shell set to C:\\Program files\\nu\\bin\\nu.exe (vim.opt.shell='C:\\Program files\\nu\\bin\\nu.exe') instead of just nu then when I try to open term it says E475: Invalid value for argument cmd: 'C:Program' is not executable:

So tbh it very much seems like neovim is doing something wrong with paths on windows. Maybe I should file an issue there.
And all of them escape correctly. So it's again either a problem with my shell
What is nu.exe? Is it nushell? nvim-tree and most vim tools expect a posix compatible shell like bash, zsh or even fish.
shellescape will produce a posix shell friendly path. It behaves differently for csh and fish, but not nu.
Please change the shell back to the default (bash?) and test again. You can launch nvim --clean to experiment with this.
When I change it to cmd (default shell on windows) it actually works, everything loads fast, ToggleTerm works, using filter commands (:!cmd) works, etc.
But it still seems like there's an issue with neovim. If it works with cmd it should work with nu too - cmd is not posix in any way as far as I can tell.
What's weird are the paths. It really looks like a bug, because it's not shell related and it SHOULD work IMO. When I change sh to C:\\Windows\\System32\\cmd.exe it's the same error (it removes \\ from the path, that shouldn't happen IMO).
Is really my only way to change to cmd temporarily (maybe make some autostart command that will fire up nu everytime cmd opens up) and open an issue/pr in neovim for better windows support?
When I change
shtoC:\\Windows\\System32\\cmd.exeit's the same error
If it is working with cmd but not the above, it is likely shellescape special case handling in nvim for exactly cmd.
open an issue/pr in neovim for better windows support?
Yes, specifically better windows support for nu shell.
When opening an issue, it's best to provide a clean, simple reproducer with no plugins. Something like:
nvim --clean
set sh=cmd
echo shellescape('/mnt/c/some/path') Output c:\some\path` (good)
nvim --clean
set sh=nu
echo shellescape('/mnt/c/some/path') Output "c:/some/path"` (bad)
The paths are just a guess; you'll need to generate the bad path to use. Put the following first line in lua/nvim-tree/git/utils.lua:
  log.line("git", "get_toplevel cwd |%s|", cwd)
This doesn't appear to be neovide related; it seem to be a neovim / nu issue.
I've encountered similar issue with neo-tree, where the author found a fix. Is there any takeaway for nvim-tree?
https://github.com/kyazdani42/nvim-tree.lua/pull/1550 potentially fixes this.
I was having trouble with junk from the shell being put into nvim-tree somehow, causing this error. Turns out, this was because i was putting stuff outside of
if status is-interactive ... end
in config.fish
putting stuff outside of
Nice one!
Please update to latest and test, as #1550 has been merged.
For myself I can confirm this resolved the issue.
For myself I can confirm this resolved the issue.
Thanks @Pernick
~~Very glad to see that this approach works on windows.~~
Shell "escapes" appears to be resolved. Please reopen if the problem persists.
Cant confirm on windows, I am running it on macos.
I faced the similar issue:
[NvimTree] Could not start the fs_event watcher for path ~/.config/lvim/plugin : ENOSPC
When I set filesystem_watchers.enable = false, it disappeared.
Is your disk full by any chances?