Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvim-tree/explorer/init.lua:66: attempt to index field 'uv' (a nil value) #2976

Closed
chenyekun1 opened this issue Oct 28, 2024 · 5 comments · Fixed by #2977
Closed

nvim-tree/explorer/init.lua:66: attempt to index field 'uv' (a nil value) #2976

chenyekun1 opened this issue Oct 28, 2024 · 5 comments · Fixed by #2977
Labels
bug Something isn't working

Comments

@chenyekun1
Copy link

Description

nvim-tree/explorer/init.lua:66: attempt to index field 'uv' (a nil value).

Neovim version

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

Windows 10

Windows variant

WSL1

nvim-tree version

8f97487

Clean room replication

require("nvim-tree").setup({
        renderer = {
                icons = {
                        show = {
                                file = false,
                                folder = false,
                                folder_arrow = false,
                                git = false,
                        },
                },
        },
        filters = {
                dotfiles = true,
        },
})

Steps to reproduce

This error occurs after :NvimTreeToggle

Expected behavior

open file tree normally.

Actual behavior

No response

@chenyekun1 chenyekun1 added the bug Something isn't working label Oct 28, 2024
@DrOptix
Copy link

DrOptix commented Oct 28, 2024

I'm having the same issue when I do :NvimTreeToggle.

@benallen-dev
Copy link

benallen-dev commented Oct 28, 2024

I did some quick in-place hacking to be able to get back to work, perhaps it helps

diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua
index 4cc511b..716765c 100644
--- a/lua/nvim-tree/explorer/init.lua
+++ b/lua/nvim-tree/explorer/init.lua
@@ -63,8 +63,10 @@ function Explorer:create(path)
 
   o.explorer = o
 
-  o.uid_explorer = vim.uv.hrtime()
-  o.augroup_id = vim.api.nvim_create_augroup("NvimTree_Explorer_" .. o.uid_explorer, {})
+  if vim.uv then
+    o.uid_explorer = vim.uv.hrtime()
+    o.augroup_id = vim.api.nvim_create_augroup("NvimTree_Explorer_" .. o.uid_explorer, {})
+  end
 
   o.open = true
   o.opts = config
@@ -114,7 +116,7 @@ function Explorer:create_autocmds()
   vim.api.nvim_create_autocmd("BufReadPost", {
     group = self.augroup_id,
     callback = function(data)
-      if (self.filters.config.filter_no_buffer or self.opts.highlight_opened_files ~= "none") and vim.bo[data.buf].buftype == "" then
+      if (self.uid_explorer and (self.filters.config.filter_no_buffer or self.opts.highlight_opened_files ~= "none")) and vim.bo[data.buf].buftype == "" then
         utils.debounce("Buf:filter_buffer_" .. self.uid_explorer, self.opts.view.debounce_delay, function()
           self:reload_explorer()
         end)
@@ -168,7 +170,8 @@ function Explorer:create_autocmds()
     })
   end
 
-  if self.opts.modified.enable then
+  if self.opts.modified.enable and self.uid_explorer then
     vim.api.nvim_create_autocmd({ "BufModifiedSet", "BufWritePost" }, {
       group = self.augroup_id,
       callback = function()

@benallen-dev
Copy link

benallen-dev commented Oct 28, 2024

I should point out that this isn't a fix, it just avoids the errors I've run into.

:version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1710088188

@DrOptix
Copy link

DrOptix commented Oct 28, 2024

Found this in neovim repo. It seems we need neovim 0.10 for vim.uv to work. I just checked and indeed I'm using neovim 0.9.5.
They suggest we use vim.loop for 0.9.5. I'll try that just to get going again. If not later I'll build neovim from sources.
neovim/neovim#27957

Update: I ended up upgrading from Fedora 39 to Fedora 40 and now I have access to neovim 0.10. For me this is no longer an issue.

@alex-courtis
Copy link
Member

Many thanks all for finding this one.

Used vim.loop instead. That won't be removed until neovim 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants