Skip to content

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

Description

@rafaelbreno

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions