nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.19k stars 609 forks source link

git integration not working in Windows. #2466

Closed peter-lyr closed 11 months ago

peter-lyr commented 1 year ago

Description

5 git jobs have timed out after git.timeout 400ms, disabling git integration.

Neovim version

NVIM v0.9.2
Build type: RelWithDebInfo
LuaJIT 2.1.1694082368

Operating system and version

Windows 10

nvim-tree version

53b0bca

Clean room replication

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {
    git = {
        enable = true,
        ignore = false,
    },
    filesystem_watchers = {
        enable = false,
        debounce_delay = 50,
    },
    log = {
        enable = true,
        types = {
            all = false,
            config = false,
            copy_paste = false,
            dev = false,
            diagnostics = false,
            git = true,
            profile = false,
            watcher = true,
        },
    },
    diagnostics = {
        enable = true,
        show_on_dirs = false,
    },
    update_focused_file = {
        enable = true
    },
    renderer = {
        group_empty = true,
    },
    filters = {
        dotfiles = false,
    },
  }
end

Steps to reproduce

  1. nvim -nu C:\Users\l\Desktop\nvt-min.lua
  2. :NvimTreeOpen

Expected behavior

git highlight status

Actual behavior

5 git jobs have timed out after git.timeout 400ms, disabling git integration.

nvim-tree.log:

[2023-10-14 00:43:18] [git] git -C C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config rev-parse --show-toplevel --absolute-git-dir C:/nv/nvim-win64-092/share/nvim/runtime/pack/nvim_config C:/nv/nvim-win64-092/share/nvim/runtime/pack/nvim_config/.git [2023-10-14 00:43:19] [git] git -C C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config config status.showUntrackedFiles fatal: cannot change to 'C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config ': Invalid argument [2023-10-14 00:43:19] [git] running job with timeout 400ms [2023-10-14 00:43:19] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u [2023-10-14 00:43:19] [git] job timed out C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil [2023-10-14 00:43:25] [git] running job with timeout 400ms [2023-10-14 00:43:25] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u [2023-10-14 00:43:26] [git] job timed out C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil [2023-10-14 00:43:27] [git] running job with timeout 400ms [2023-10-14 00:43:27] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u [2023-10-14 00:43:28] [git] job timed out C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil [2023-10-14 00:43:28] [git] running job with timeout 400ms [2023-10-14 00:43:28] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u [2023-10-14 00:43:28] [git] job timed out C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil [2023-10-14 00:43:28] [git] running job with timeout 400ms [2023-10-14 00:43:28] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u [2023-10-14 00:43:29] [git] job timed out C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil [2023-10-14 00:43:29] [git] disabling git integration [2023-10-14 00:43:29] [git] purge_state

gegoune commented 1 year ago

You could try increasing timeout, it might be genuine slowness of your system. Please bump :h nvim-tree.git.timeout to some higher value.

peter-lyr commented 1 year ago

I have tried. It's not working and it stucked for a long time.

peter-lyr commented 1 year ago

It is 28c3980b25e50e9ede39df55427151cb11be46f9 and later commits that make git status highlight not working. Thx.

alex-courtis commented 1 year ago
[2023-10-14 00:43:19] [git] git -C C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config
config status.showUntrackedFiles
fatal: cannot change to 'C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config
': Invalid argument

This looks like it might be a path escaping issue. https://github.com/nvim-tree/nvim-tree.lua/commit/28c3980b25e50e9ede39df55427151cb11be46f9 did make a change to always use absolute paths, to allow for worktrees etc.

Please revert to 0074120 , repeat the test and report the logs.

alex-courtis commented 1 year ago

You could try increasing timeout, it might be genuine slowness of your system.

That sounds likely.

How long does git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u actually take?

On UNIX we'd do something like:

: ; time git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u
!! doc/tagsgit --no-optional-locks status --porcelain=v1 -z --ignored=matching -u  0.00s user 0.01s system 89% cpu 0.006 total

I do not know what the windows equivalent of time is.

peter-lyr commented 1 year ago

I reverted to 00741206c2df9c4b538055def19b99790f0c95c8.

in git bash:

l@DESKTOP-STCN8A0 MINGW64 /c/nv/nvim-win64-092/share/nvim/runtime/pack/nvim_config (lsp_cmp)
$ time git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u
!! cli/neovim.ico.o !! nvim_qt_here.exe !! nvim_qt_here.reg !! open-with-cmd.exe !! open-with-ps1.exe !! rm_nvim_qt_here.reg !! start-nvim-qt.exe !! start/lazy/lua/plugins/nvimtree_oftendirs.exe
real    0m0.040s
user    0m0.000s
sys     0m0.015s

nvim-tree.log

[2023-10-15 11:42:28] [git] { "git", "-C", "C:\\nv\\nvim-win64-092\\share\\nvim\\runtime\\pack\\nvim_config", "rev-parse", "--show-toplevel" }
C:/nv/nvim-win64-092/share/nvim/runtime/pack/nvim_config
[2023-10-15 11:42:28] [git] { "git", "-C", "C:\\nv\\nvim-win64-092\\share\\nvim\\runtime\\pack\\nvim_config", "config", "status.showUntrackedFiles" }
[2023-10-15 11:42:28] [git] running job with timeout 400ms
[2023-10-15 11:42:28] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u
!! cli/neovim.ico.o
!! nvim_qt_here.exe
!! nvim_qt_here.reg
!! open-with-cmd.exe
!! open-with-ps1.exe
!! rm_nvim_qt_here.reg
!! start-nvim-qt.exe
!! start/lazy/lua/plugins/nvimtree_oftendirs.exe
[2023-10-15 11:42:28] [git] done
[2023-10-15 11:42:28] [git] job success    C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil
[2023-10-15 11:42:59] [watcher] purge_watchers
[2023-10-15 11:42:59] [git] purge_state
[2023-10-15 11:42:59] [watcher] purge_watchers
[2023-10-15 11:42:59] [watcher] purge_watchers
[2023-10-15 11:43:10] [git] { "git", "-C", "C:\\nv\\nvim-win64-092\\share\\nvim\\runtime\\pack\\nvim_config", "rev-parse", "--show-toplevel" }
C:/nv/nvim-win64-092/share/nvim/runtime/pack/nvim_config
[2023-10-15 11:43:10] [git] running job with timeout 400ms
[2023-10-15 11:43:10] [git] git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u
!! cli/neovim.ico.o
!! nvim_qt_here.exe
!! nvim_qt_here.reg
!! open-with-cmd.exe
!! open-with-ps1.exe
!! rm_nvim_qt_here.reg
!! start-nvim-qt.exe
!! start/lazy/lua/plugins/nvimtree_oftendirs.exe
[2023-10-15 11:43:10] [git] done
[2023-10-15 11:43:10] [git] job success    C:\nv\nvim-win64-092\share\nvim\runtime\pack\nvim_config nil
alex-courtis commented 1 year ago

Issue could be related to #2467 Normalising paths may resolve this.

Which variant of windows are you using @peter-lyr ? Powershell, WLS, msys, cygwin, something else?

I'd be most grateful if you ran a feature flag audit for your windows variant, to assist us in dealing with future issues.

Please open and :source this feature flag enumerator: has.lua.gz

peter-lyr commented 1 year ago

Thank you @alex-courtis.

I didn't use any CLI. I just open nvim-qt.exe.

has_list.log

bsd=0
linux=0
sun=0
unix=0
win32=1
win64=1
fname_case=0
acl=0
autochdir=1
arabic=1
autocmd=1
browsefilter=1
byte_offset=1
cindent=1
cmdline_compl=1
cmdline_hist=1
cmdwin=1
comments=1
conceal=1
cursorbind=1
cursorshape=1
dialog_con=1
diff=1
digraphs=1
eval=1
ex_extra=1
extra_search=1
file_in_path=1
filterpipe=1
find_in_path=1
float=1
folding=1
fork=0
gettext=1
iconv=1
insert_expand=1
jumplist=1
keymap=1
lambda=1
langmap=1
libcall=1
linebreak=1
lispindent=1
listcmds=1
localmap=1
mac=0
macunix=0
osx=0
osxdarwin=0
menu=1
mksession=1
modify_fname=1
mouse=1
multi_byte=1
multi_lang=1
nanotime=1
num64=1
packages=1
path_extra=1
persistent_undo=1
profile=1
pythonx=1
reltime=1
quickfix=1
rightleft=1
scrollbind=1
showcmd=1
cmdline_info=1
shada=1
signs=1
smartindent=1
startuptime=1
statusline=1
spell=1
syntax=1
system=1
tablineat=1
tag_binary=1
termguicolors=1
termresponse=1
textobjects=1
timers=1
title=1
user_commands=1
vartabs=1
vertsplit=1
virtualedit=1
visual=1
visualextra=1
vreplace=1
wildignore=1
wildmenu=1
windows=1
winaltkeys=1
writebackup=1
nvim=1
gui_running=1
patch=0
ttyin=0
ttyout=0
multi_byte_encoding=1
syntax_items=0
clipboard_working=1
clipboard=1
wsl=0
vim_starting=0
alex-courtis commented 1 year ago

Many thanks for the feature flags @peter-lyr , it was very enlightening: https://github.com/nvim-tree/nvim-tree.lua/wiki/Development#os-feature-flags

alex-courtis commented 1 year ago

@peter-lyr I'd be most grateful if you tested an attempted fix:

I'm flying pretty blind here so we might need a few rounds of testing.

cd /path/to/nvim-tree.lua
git pull
git checkout 2466-windows-git-failures

My hypothesis is that git -C ... rev-parse --show-toplevel --absolute-git-dir is returning \r instead of or in addition to `\n'.

alex-courtis commented 1 year ago

A more comprehensive fix has been applied and has been released on master: #2478

@peter-lyr please update nvim-tree to current master or later and re-test.

alex-courtis commented 11 months ago

The fix seems stable for other cases / users, as no news is good news.

Please reopen if you experience further issues.

jinzhongjia commented 9 months ago

em.. This problem still seems to be triggered (I can't stably surface it yet), I have adjusted the timeout to 1000

jinzhongjia commented 9 months ago

I have now enabled the log of nvim-tree. I will report when it occurs.