nvim-tree / nvim-tree/nvim-tree.lua

Bug: `vim.system():wait()` fails with "bad argument #1 to 'wait'" on Neovim 0.11.5

Open
#3,251 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
8.6k
Forks
639
Avg merge
1d 14h
Merged PRs (30d)
2

Description

Description

When opening nvim-tree in a git repository on Neovim 0.11.5, the git integration fails with an error in lua/nvim-tree/git/utils.lua. The vim.system(cmd):wait() call on line 14 throws an error because :wait() receives nil instead of the expected number.

Neovim version

NVIM v0.11.5

nvim-tree version

Commit: 5757bcf0447d22bc5c59b28da2824c3b
Message: fix(#3248): bookmark filter shows contents of marked directories (#3249)

Minimal config

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

require("nvim-tree").setup({})

Steps to reproduce

  1. Open Neovim 0.11.5 inside a git repository
  2. Run :NvimTreeToggle

Error message

Error executing Lua callback: /usr/local/share/nvim/runtime/lua/vim/_system.lua:87: bad argument #1 to 'wait' (number expected, got nil)
stack traceback:
        [C]: in function 'wait'
        /usr/local/share/nvim/runtime/lua/vim/_system.lua:87: in function 'wait'
        ...nvim-tree.lua/lua/nvim-tree/git/utils.lua:14: in function 'system'
        ...nvim-tree.lua/lua/nvim-tree/git/utils.lua:32: in function 'get_toplevel'
        ...nvim-tree.lua/lua/nvim-tree/git/init.lua:197: in function 'get_toplevel'
        ...nvim-tree.lua/lua/nvim-tree/git/init.lua:274: in function 'load_project'
        ...nvim-tree.lua/lua/nvim-tree/explorer/init.lua:350: in function '_load'
        ...nvim-tree.lua/lua/nvim-tree/explorer/init.lua:72: in function 'new'
        ...nvim-tree.lua/lua/nvim-tree/classic.lua:82: in function <...nvim-tree.lua/lua/nvim-tree/classic.lua:80>
        ...nvim-tree.lua/lua/nvim-tree/core.lua:28: in function 'init'
        ...nvim-tree.lua/lua/nvim-tree/lib.lua:106: in function 'open'
        ...nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:48: in function 'toggle'
        ...nvim-tree.lua/lua/nvim-tree/commands.lua:33: in function <...nvim-tree.lua/lua/nvim-tree/commands.lua:32>

Expected behavior

NvimTree should open normally with git status indicators displayed.

Workaround

Disabling git integration resolves the issue:

require("nvim-tree").setup({
  git = {
    enable = false,
  },
})

Possible fix

The issue is in lua/nvim-tree/git/utils.lua line 14. Adding an explicit timeout to :wait() seems to resolve the issue:

-- Current code (line 14):
local obj = vim.system(cmd):wait()

-- Suggested fix:
local obj = vim.system(cmd):wait(5000)

It appears that in Neovim 0.11.x, vim.system():wait() without arguments may behave differently than in 0.10.x.

Neovim version
NVIM v0.11.5
Build type: RelWithDebInfo
LuaJIT 2.1.1741730670
Operating system and version

Linux 6.18.5-arch1-1

Windows variant

No response

nvim-tree version

5757bcf

Clean room replication
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

require("nvim-tree").setup({})
Steps to reproduce
  1. Open Neovim 0.11.5 inside a git repository
  2. Run :NvimTreeToggle
Expected behavior

NvimTree should open normally with git status indicators displayed.

Workaround is to disable git:

require("nvim-tree").setup({
  git = {
    enable = false,
  },
})
Actual behavior

Throws error:

Error executing Lua callback: /usr/local/share/nvim/runtime/lua/vim/_system.lua:87: bad argument #1 to 'wait' (number expected, got nil)
stack traceback:
        [C]: in function 'wait'
        /usr/local/share/nvim/runtime/lua/vim/_system.lua:87: in function 'wait'
        ...nvim-tree.lua/lua/nvim-tree/git/utils.lua:14: in function 'system'
        ...nvim-tree.lua/lua/nvim-tree/git/utils.lua:32: in function 'get_toplevel'
        ...nvim-tree.lua/lua/nvim-tree/git/init.lua:197: in function 'get_toplevel'
        ...nvim-tree.lua/lua/nvim-tree/git/init.lua:274: in function 'load_project'
        ...nvim-tree.lua/lua/nvim-tree/explorer/init.lua:350: in function '_load'
        ...nvim-tree.lua/lua/nvim-tree/explorer/init.lua:72: in function 'new'
        ...nvim-tree.lua/lua/nvim-tree/classic.lua:82: in function <...nvim-tree.lua/lua/nvim-tree/classic.lua:80>
        ...nvim-tree.lua/lua/nvim-tree/core.lua:28: in function 'init'
        ...nvim-tree.lua/lua/nvim-tree/lib.lua:106: in function 'open'
        ...nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:48: in function 'toggle'
        ...nvim-tree.lua/lua/nvim-tree/commands.lua:33: in function <...nvim-tree.lua/lua/nvim-tree/commands.lua:32>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lua/nvim-tree/git/utils.lua line 14 and reproduce with Neovim 0.11.5 in a Git repository using the minimal configuration and :NvimTreeToggle. Verify the change against the reported wait error and confirm that NvimTree opens with git status indicators enabled, while git-disabled behavior remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.