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

Windows Neotree cwd and Gitsigns prevents Neovim exit (LazyVim) #1027

Closed
Kayzels opened this issue May 31, 2024 · 25 comments · Fixed by #1031 or #1011
Closed

Windows Neotree cwd and Gitsigns prevents Neovim exit (LazyVim) #1027

Kayzels opened this issue May 31, 2024 · 25 comments · Fixed by #1031 or #1011
Labels
bug Something isn't working windows Issue specific to the windows platform

Comments

@Kayzels
Copy link

Kayzels commented May 31, 2024

Description

This happens specifically with a LazyVim setup, but they cannot reproduce it, so checking if there might be more luck here.

Using Neotree, you can change the current working directory by pressing .. Doing this in a git repo, or changing to git repo using it, causes Neovim to freeze on exit. Importantly, it only seems to happen if the Neovim is started in a folder that is a git repo.

Maybe its having an issue with the cwd update? The maintainers of the LazyVim repo couldn't reproduce, so possibly its Windows specific? I noticed that the last working commit that didn't cause this was cdfcd9d - it broke from 720061a.

Any non-git folders aren't affected, and using an older version of gitsigns doesn't cause the issue.

Unfortunately, because it's happening with LazyVim, the repro needs to include that, so it's not particularly small any more.

Neovim version

NVIM v0.10.0 Release

Operating system and version

Windows 10 Pro 22H2 19045.3803

Expected behavior

Neovim should exit without freezing the terminal.

Actual behavior

Neovim hangs on exit.

Nvim_not_closing_gitsigns.mp4

Minimal config

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "LazyVim/LazyVim",
    import = "lazyvim.plugins",
    -- version = "10.x"
  },
  {
    "lewis6991/gitsigns.nvim",
    opts = {
      debug_mode = true,
    },
  },
  {
    "nvim-neo-tree/neo-tree.nvim",
    opts = {
      filesystem = {
        bind_to_cwd = true, -- Lazy sets it to false
        follow_current_file = { enabled = false }, -- Lazy sets it to true
        use_libuv_file_watcher = false,
      },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

Steps to reproduce

  1. Copy the code above and save in a new folder in file called repro.lua (or `minimal.lua, but then you need to update the nvim command.
  2. Make the downloaded code part of a git repo, by typing git init
  3. nvim --clean -u repro.lua
  4. Open the repro.lua file from Neotree, navigating to it by typing :Neotree.
  5. Use Neotree to navigate to some other files, using Backspace to go up a folder.
  6. After the files are opened, navigate back to the created repo, and select the repro.lua file.
  7. Open Neotree again, press Backspace to see a list of the directories including the created one containing the repro.lua file.
  8. Press . on the folder that contains the repro.lua file.
  9. Go back to the repro.lua file.
  10. Try to close Neovim by entering :qa.

Gitsigns debug messages

dprintf: Highlight GitSignsAdd is already defined
dprintf: Highlight GitSignsChange is already defined
dprintf: Highlight GitSignsDelete is already defined
dprintf: Deriving GitSignsChangedelete from GitSignsChange
dprintf: Deriving GitSignsTopdelete from GitSignsDelete
dprintf: Deriving GitSignsUntracked from GitSignsAdd
dprintf: Deriving GitSignsAddNr from GitGutterAddLineNr
dprintf: Deriving GitSignsChangeNr from GitGutterChangeLineNr
dprintf: Deriving GitSignsDeleteNr from GitGutterDeleteLineNr
dprintf: Deriving GitSignsChangedeleteNr from GitSignsChangeNr
dprintf: Deriving GitSignsTopdeleteNr from GitSignsDeleteNr
dprintf: Deriving GitSignsUntrackedNr from GitSignsAddNr
dprintf: Deriving GitSignsAddLn from DiffAdd
dprintf: Deriving GitSignsChangeLn from DiffChange
dprintf: Deriving GitSignsChangedeleteLn from GitSignsChangeLn
dprintf: Deriving GitSignsUntrackedLn from GitSignsAddLn
dprintf: Deriving GitSignsStagedAdd from GitSignsAdd
dprintf: Deriving GitSignsStagedChange from GitSignsChange
dprintf: Deriving GitSignsStagedDelete from GitSignsDelete
dprintf: Deriving GitSignsStagedChangedelete from GitSignsChangedelete
dprintf: Deriving GitSignsStagedTopdelete from GitSignsTopdelete
dprintf: Deriving GitSignsStagedAddNr from GitSignsAddNr
dprintf: Deriving GitSignsStagedChangeNr from GitSignsChangeNr
dprintf: Deriving GitSignsStagedDeleteNr from GitSignsDeleteNr
dprintf: Deriving GitSignsStagedChangedeleteNr from GitSignsChangedeleteNr
dprintf: Deriving GitSignsStagedTopdeleteNr from GitSignsTopdeleteNr
dprintf: Deriving GitSignsStagedAddLn from GitSignsAddLn
dprintf: Deriving GitSignsStagedChangeLn from GitSignsChangeLn
dprintf: Could not derive GitSignsStagedDeleteLn
dprintf: Deriving GitSignsStagedChangedeleteLn from GitSignsChangedeleteLn
dprintf: Could not derive GitSignsStagedTopdeleteLn
dprintf: Deriving GitSignsAddPreview from DiffAdd
dprintf: Deriving GitSignsDeletePreview from DiffDelete
dprintf: Deriving GitSignsCurrentLineBlame from NonText
dprintf: Deriving GitSignsAddInline from TermCursor
dprintf: Deriving GitSignsDeleteInline from TermCursor
dprintf: Deriving GitSignsChangeInline from TermCursor
dprintf: Deriving GitSignsAddLnInline from GitSignsAddInline
dprintf: Deriving GitSignsChangeLnInline from GitSignsChangeInline
dprintf: Deriving GitSignsDeleteLnInline from GitSignsDeleteInline
dprintf: Deriving GitSignsDeleteVirtLn from DiffDelete
dprintf: Deriving GitSignsDeleteVirtLnInLine from GitSignsDeleteLnInline
dprintf: Deriving GitSignsVirtLnum from GitSignsDeleteVirtLn
attach(2): Attaching (trigger=setup)
attach(2): Non-normal buffer
attach(3): Attaching (trigger=setup)
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
run_job: git --version
run_job: git --version
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --short HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --short HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir C:/Users/Kyzan/Documents/Test/Gitsigns_Broken/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol C:\Users\Kyzan\Documents\Test\Gitsigns_Broken\repro.lua
attach(3): File is untracked
detach(4): Detached
detach(4): Cache was nil
attach(4): Attaching (trigger=BufFilePost)
attach(4): Non-normal buffer
attach(5): Attaching (trigger=BufReadPost)
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
new: Not in git repo
attach(5): Empty git obj
attach(6): Attaching (trigger=BufReadPost)
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
new: Not in git repo
attach(6): Empty git obj
cli.run: Running action 'debug_messages' with arguments {}
cli.run: Running action 'debug_messages' with arguments {}
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --short HEAD
cwd_watcher_cb: Git cwd dir update
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --short HEAD
cli.run: Running action 'debug_messages' with arguments {}
cli.run: Running action 'debug_messages' with arguments {}
cli.run: Running action 'debug_messages' with arguments {}
@Kayzels Kayzels added the bug Something isn't working label May 31, 2024
@lewis6991
Copy link
Owner

lewis6991 commented May 31, 2024

Please remove lazy.nvim from the repro steps.

Also note I don't have access to Windows, so it is unlikely anyone will fix this.

@lewis6991 lewis6991 added the windows Issue specific to the windows platform label May 31, 2024
@Kayzels
Copy link
Author

Kayzels commented May 31, 2024

Please remove lazy.nvim from the repro steps.

Unfortunately it's got to do with the LazyVim integration. Without LazyVim, the error doesn't happen. But it also only happens in LazyVIm if gitsigns is enabled, and the commit is later than cdfcd9d.

Also note I don't have access to Windows, so it is unlikely anyone will fix this.

Yeah, being on Windows is more trouble than its worth. I'm strongly considering moving to Linux, but unfortunately still need Windows for university stuff.

From what I can tell, gitsigns is preventing Neovim from closing because it thinks there's still a git repo open.

I understand not being able to fix it -- I can just keep it pinned to the commit that still works, if there is no obvious way to resolve it.

@sinkr
Copy link

sinkr commented May 31, 2024

I am on macOS and have had separate issues (startup backtrace) on anything after cdfcd9d39d23c46ae9a040de2c6a8b8bf868746e + LazyVim myself, which I brought up on the Gitter discussion board.

I bring it up here because of the common denominator of the commit, even though we have completely different behaviors. I have opened this discussion item on the LazyVim side because I doubt I have enough info to open a proper issue.

@lewis6991
Copy link
Owner

Let's not conflate all backtrace issues into one. From what I can tell they are separate issues.

@bruxisma
Copy link

bruxisma commented Jun 4, 2024

Hello,

I'm running into this issue as well. It happens if using gitsigns without a manager, and just doing the normal setup song + dance. I noticed that there is always a git.exe instance in the background that just refuses to close.

If there was a way we could force gitsigns to disengage or "close" these git instances during the ExitPre or VimLeavePre autocmd, I think that would be an OK workaround on windows. I'd had to uninstall gitsigns, as it's made my life easier when I need to edit projects on Windows.

As it stands now, even :qa! can block on exit 😞

@Kayzels
Copy link
Author

Kayzels commented Jun 4, 2024

@bruxisma would you be able to create a reproducible version that doesn't use LazyVim, then? I have noticed that some tasks don't close when Neovim does, so it's possibly a Neovim issue, not just restricted to Gitsigns. For me, I've noticed I've needed to manually stop the lsp servers under the nvim process from Task Manager. LuaLS especially likes to keep itself open.

For now, you don't need to uninstall Gitsigns, you could just pin it to the commit before it stopped working.

@lewis6991
Copy link
Owner

Apparently someone had a similar issue and was resolved by removing a call to setup() as they were calling it twice. Even though setup() is allowed to be called multiple times, I can theorize how some of the recent refactorings may introduce the potential for some issues.

If anyone can confirm this, that would be helpful. Otherwise, this still needs to be debugged by someone who can reproduce the issue.

@sinkr
Copy link

sinkr commented Jun 4, 2024

I think I can mostly confirm this. I say mostly, because I did not scour the Lazy source code to find an explicit setup() call, but I assume there must be one when I enable the plugin.

My issues, which were an intermittent once every other or three startup stacktraces, went away when I made the below material change (removing the setup() call) to my .config/nvim/plugins/lua GitSigns additional config Lua.

The normal pattern, mostly, is to duplicate the setup inside a return, so I was quite baffled for a long time until I saw a post somewhere that prompted me to try using just opts outside of a setup().

   1   │ diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua
   2   │ index 5d46475f..b93b71a2 100644
   3   │ --- a/.config/nvim/lua/plugins/gitsigns.lua
   4   │ +++ b/.config/nvim/lua/plugins/gitsigns.lua
   5   │ @@ -1,8 +1,7 @@
   6   │  return {
   7   │    "lewis6991/gitsigns.nvim",
   8   │ -  enabled = true,
   9   │ -  require("gitsigns").setup({
  10   │ -
  11   │ +  event = "LazyFile",
  12   │ +  opts = {
  13   │      signs = {
  14   │        -- Colors may be changed via the according highlight groupd, check :h gitsigns-highlight-groups
  15   │        add = { text = "+" },
  16   │ @@ -50,5 +49,5 @@ return {
  17   │        row = 0,
  18   │        col = 1,
  19   │      },
  20   │ -  }),
  21   │ +  },
  22   │  }

@lewis6991
Copy link
Owner

Thank you @sinkr . This gives me a good idea where to look for issues.

@bruxisma
Copy link

bruxisma commented Jun 4, 2024

@bruxisma would you be able to create a reproducible version that doesn't use LazyVim, then? I have noticed that some tasks don't close when Neovim does, so it's possibly a Neovim issue, not just restricted to Gitsigns. For me, I've noticed I've needed to manually stop the lsp servers under the nvim process from Task Manager. LuaLS especially likes to keep itself open.

For now, you don't need to uninstall Gitsigns, you could just pin it to the commit before it stopped working.

@Kayzels So I actually don't use LazyVim at all. I use lazy.nvim as a package manager. When I was writing my comment earlier, I actually thought LazyVim was a typo that you had used to refer to lazy.nvim (I wrote my issue at 3:30 AM my time as I was pulling a late night and was tired of running into this issue)

That said, the lazy.nvim configuration I use for gitsigns is

  {
    "lewis6991/gitsigns.nvim",
    event = "VeryLazy",
    opts = {
      signs = {
        changedelete = { text = "" },
        delete = { text = "" },
        change = { text = "" },
        add = { text = "" },
      },
    },
  },

Hopefully this can add some additional information to what @sinkr showed above.

@lewis6991
Copy link
Owner

No not really. Need to be able to reproduce this without lazy, otherwise I consider this a lazy issue.

I swear VeryLazy causes more problems than it solves (none).

@bruxisma
Copy link

bruxisma commented Jun 4, 2024

As I stated in my initial comment, I was able to replicate this happening without using lazy.nvim (or VeryLazy as an event loader). I had manually cloned, manually loaded, and manually called setup() and was still having the issue.

When VeryLazy is removed, a background git.exe instance is always executing. When it is present it only happens if I'm editing in a git repository (which isn't always. sometimes I have scratch files I work on).

That said, as I'm writing this comment, I do wonder if maybe the core.fsmonitor git config setting has anything to do with it, as this was causing issues for me under a separate tool (and the fix there was to force git to execute with the fsmonitor config value forced to false). I'll try to disable the fsmonitor and see if it's the cause and report back in a little while (unfortunately, I have IRL meetings)

@bruxisma
Copy link

bruxisma commented Jun 4, 2024

Ok, after spending some time testing, core.fsmonitor does not affect whether the nvim halts on exit. However if core.fsmonitor is disabled, it freezes as it goes to "save" the current buffer. With core.fsmonitor enabled it freezes as soon as :wqa is entered.

With that said, I was able to narrow down some of the behavior. This only appears (for me) to happen in files/buffers where:

  1. signs with an add sign are present. (change and changedelete do not seem to have any affect)
  2. a buffer in a separate git repository (with no changes) is open

I'm unable to get either case to reliably happen separate from each other.

@bwpge
Copy link

bwpge commented Jun 5, 2024

Thank you @bruxisma for the detailed troubleshooting here. This makes a lot more sense and I can confirm I'm having similar problems. I've pinned to cdfcd9d and can confirm this does not have the freezing issues.

I know its been stated numerous times in this issue to remove all lazy/LazyVim references to isolate the variables, but just adding my troubleshooting steps when I initially ran into this problem (had no idea it was possibly related to gitsigns):

  • Noticed nvim freezing on exit (on a Windows system)
    • This was only happening when I opened a project that was a git repo
    • And it only happend when I opened another tab to my config (also a git repo)
  • I could reliably reproduce the problem by:
    • Opening nvim and open one file from a project I was working on (git repo)
      • It's now clear from @bruxisma's testing I was opening files that did indeed have adds (among other changes)
    • Open new tab to my config, open a file from that repo (same as above, file had adds and other changes)
    • Then close both tabs in succession with :q (final close would freeze)
  • My initial thought was that it was something to do with my "lazy" config
    • I thought there may have been some weird event interactions causing infinite loops on close
    • Couldn't find any indication of that reading through logs or anything else
  • After several hours of not being able to pinpoint the problem I disabled every plugin manually through lazy.nvim
    • Stepped through enabling every single plugin 1-by-1, issue was not happening
    • gitsigns just so happened to be the second-to-last one I enabled, freezing was back
    • Disabled everything else, enabled gitsigns and could reproduce the issue
  • Started looking through open issues, found bug: gitsigns.nvim makes Neovim randomly freeze when scrolling/switching buffers #1029 which led to this one

Again, I know this is not a sufficient troubleshooting as already discussed in this issue, but at least maybe this can help other people stepping through similar logic to find some common themes and they can help us gather more information. Unfortunately I'm not home today to work on this so I can't offer much in the way of finding a fix.

@lewis6991
Copy link
Owner

lewis6991 commented Jun 5, 2024

After several hours of not being able to pinpoint the problem I disabled every plugin manually through lazy.nvim

  • Stepped through enabling every single plugin 1-by-1, issue was not happening
  • gitsigns just so happened to be the second-to-last one I enabled, freezing was back
  • Disabled everything else, enabled gitsigns and could reproduce the issue

Is there anything preventing you from producing a testcase (as per the issue template)? Otherwise, this information is much less helpful than you think. Without being able to properly debug this, anything can be happening.

I'll copy the steps here for convenience.


Here is the template for a minimal init.lua:

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
  local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

This init.lua can be used by running git --clean -u init.lua.

Provide this along side instructions like:

  1. mkdir issue_dir
  2. cd issue_dir
  3. git init
  4. Create a file and commit it
  5. Open nvim with nvim --clean -u init.lua.
  6. and so on ...

If this is provided and I am able to reproduce this, then I can debug it and fix it.

@bwpge
Copy link

bwpge commented Jun 5, 2024

@lewis6991 sure I will work on this today, I'm a bit limited on what I can test at work but I should be able to reproduce the issues here.

@bwpge
Copy link

bwpge commented Jun 5, 2024

@lewis6991 as requested

Content of repro config init.lua:

for name, url in pairs({
    gitsigns = "https://github.com/lewis6991/gitsigns.nvim",
}) do
    local install_path = vim.fn.fnamemodify("gitsigns_issue/" .. name, ":p")
    if vim.fn.isdirectory(install_path) == 0 then
        vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
    end
    vim.opt.runtimepath:append(install_path)
end

require("gitsigns").setup({
    debug_mode = true, -- You must add this to enable debug messages
})

Steps to reproduce:

  1. Use a Windows system with Neovim 0.10
  2. mkdir issue
  3. cd issue
  4. Save above config to init.lua
  5. git init
  6. Write any text to foo.txt ("hello" works fine)
  7. git add foo.txt
  8. git commit -m foo
  9. Open foo.txt, add a new line and then some text, write and close (do not commit)
  10. mkdir dummy
  11. cd dummy
  12. Repeat steps 4-8 (e.g., create a new repo, create foo.txt with a line of text and commit, then add some more text on a new line and do not commit)
  13. cd ..
  14. nvim --clean -u init.lua
  15. :e foo.txt
  16. :tabnew
  17. :tcd dummy
  18. :e foo.txt
  19. :q (closes the tab in dummy)
  20. :q (this should cause a freeze)

The above steps could maybe be combined to be a bit less verbose but wanted to be explicit about separate commands.

NOTE: I was not able to reproduce the issue on WSL with the above steps.

@lewis6991
Copy link
Owner

lewis6991 commented Jun 5, 2024

Thanks.

I was hoping that since you can reproduce this in WSL that I could repro it on Mac, but I couldn't.

Looks like I need to build a VM to try and repro this.

EDIT: Looks like WSL doesn't work in MacOS VM's as it doesn't support nested virtualisation.

@bwpge
Copy link

bwpge commented Jun 5, 2024

I was hoping that since you can reproduce this in WSL that I could repro it on Mac, but I couldn't.

Just to clarify I can not repro in WSL :)

I'm happy to try and take a stab at it when I get home, I have a Windows machine I can work on. Running the above steps, I was not able to find any debug/log file for gitsigns -- is there something else I need to enable in the options to output it?

@lewis6991
Copy link
Owner

lewis6991 commented Jun 5, 2024

The logs are all internal to the session. You can see them by running :Gitsigns debug_messages. That will log each system command as it is spawned.

Just to clarify I can not repro in WSL :)

Ah sorry, I misread. This must indeed be a window issue.

@lewis6991
Copy link
Owner

lewis6991 commented Jun 5, 2024

Also the :tcd gives one clue as this calls the DirChanged autocmd which is setup here. This will then call update_cwd_head_debounced() which is also called during setup().

Something about that function is causing issues and might also explain why some users are getting similar problems when calling setup twice is it will invoke update_cwd_head_debounced() again.

@bwpge
Copy link

bwpge commented Jun 5, 2024

As maybe an exercise in futility, I edited the cprint log function to write to an output file with millisecond second timestamps. I wanted to see if I could capture anything useful when the freeze occurs since I can't run commands at that point, and wanted to have a sense of time when reading.

+local log_file = vim.uv.cwd() .. '/gitsigns.log'

 -- If called in a callback then make sure the callback defines a __FUNC__
 -- variable which can be used to identify the name of the function.
 --- @param obj any
 --- @param lvl integer
 local function cprint(obj, lvl)
   ...
   table.insert(M.messages, msg2)

+  local f = assert(io.open(log_file, 'ab'))
+  local sec = vim.uv.gettimeofday() -- I'm dumb, these are seconds
+  f:write(sec .. ' ' .. msg2)
+  f:write('\n')
+  f:flush()
+  f:close()
 end

I don't see much here but maybe you'll see something useful.

The only thing I found remotely interesting is that the cwd_watcher_cb fires at essentially the same time as detach (1717618371 and 1717618372), presumably when :q is ran on the last buffer. No idea if this is expected behavior so don't want to speculate too much.

EDIT: never mind I'm an idiot, those were seconds not ms... 🤦

Log output
1717618357 run_job: git --version
1717618357 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618357 git_command: 3 lines:
1717618357 git_command: 	X:/issue
1717618357 git_command: 	X:/issue/.git
1717618357 git_command: 	main
1717618359 attach(1): Attaching (trigger=BufReadPost)
1717618359 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
1717618359 git_command: 1 lines:
1717618359 git_command: 	bwpge
1717618359 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618359 git_command: 3 lines:
1717618359 git_command: 	X:/issue
1717618359 git_command: 	X:/issue/.git
1717618359 git_command: 	main
1717618359 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir X:/issue/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol X:\issue\foo.txt
1717618359 command: 1 lines:
1717618359 command: 	100644 ce013625030ba8dba906f756967f9e9ca394464a 0	i/lf    w/lf    attr/                 	foo.txt
1717618359 watch_gitdir(1): Watching git dir
1717618359 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir X:/issue/.git show ce013625030ba8dba906f756967f9e9ca394464a
1717618359 command: 2 lines:
1717618359 command: 	hello
1717618359 command: 	
1717618365 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618365 git_command: 3 lines:
1717618365 git_command: 	X:/issue/dummy
1717618365 git_command: 	X:/issue/dummy/.git
1717618365 git_command: 	main
1717618365 cwd_watcher_cb: Git cwd dir update
1717618365 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618365 git_command: 3 lines:
1717618365 git_command: 	X:/issue/dummy
1717618365 git_command: 	X:/issue/dummy/.git
1717618365 git_command: 	main
1717618369 attach(2): Attaching (trigger=BufReadPost)
1717618369 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 config user.name
1717618369 git_command: 1 lines:
1717618369 git_command: 	bwpge
1717618369 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618369 git_command: 3 lines:
1717618369 git_command: 	X:/issue/dummy
1717618369 git_command: 	X:/issue/dummy/.git
1717618369 git_command: 	main
1717618369 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir X:/issue/dummy/.git -c core.quotepath=off ls-files --stage --others --exclude-standard --eol X:\issue\dummy\foo.txt
1717618369 command: 1 lines:
1717618369 command: 	100644 ce013625030ba8dba906f756967f9e9ca394464a 0	i/lf    w/lf    attr/                 	foo.txt
1717618369 watch_gitdir(2): Watching git dir
1717618369 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 --git-dir X:/issue/dummy/.git show ce013625030ba8dba906f756967f9e9ca394464a
1717618369 command: 2 lines:
1717618369 command: 	hello
1717618369 command: 	
1717618371 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618371 git_command: 3 lines:
1717618371 git_command: 	X:/issue
1717618371 git_command: 	X:/issue/.git
1717618371 git_command: 	main
1717618371 cwd_watcher_cb: Git cwd dir update
1717618371 run_job: git --no-pager --no-optional-locks --literal-pathspecs -c gc.auto=0 rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD
1717618371 git_command: 3 lines:
1717618371 git_command: 	X:/issue
1717618371 git_command: 	X:/issue/.git
1717618371 git_command: 	main
1717618372 detach(1): Detached
1717618372 detach(2): Detached

@dundargoc
Copy link
Collaborator

dundargoc commented Jun 6, 2024

Running on debug mode gives

Assertion failed: req != current, file C:\Users\gocdu\programs\neovim\.deps\build\src\libuv\src\win\req-inl.h, line 99

which is referencing this line.


Easier reproduction steps:

Run nvim --clean -u init.lua where init.lua is

for name, url in pairs({
    gitsigns = "https://github.com/lewis6991/gitsigns.nvim",
}) do
    local install_path = vim.fn.fnamemodify("gitsigns_issue/" .. name, ":p")
    if vim.fn.isdirectory(install_path) == 0 then
        vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
    end
    vim.opt.runtimepath:append(install_path)
end

require("gitsigns").setup({
    debug_mode = true, -- You must add this to enable debug messages
})

vim.cmd[[tabnew]]
vim.cmd[[tcd ..]]

Creating git repos, commiting files and the other stuff is not necessary, just run the above anywhere and quit neovim.

@dundargoc
Copy link
Collaborator

dundargoc commented Jun 6, 2024

Minimaler repro:

Run nvim --clean -u freeze.lua where freeze.lua is

local watcher = assert(vim.uv.new_fs_event())

watcher:start('.', {}, function()
  print('hello')
end)

watcher:stop()

watcher:start('.', {}, function()
  print('bye')
end)

@lewis6991
Copy link
Owner

Can people try #1031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Issue specific to the windows platform
Projects
None yet
6 participants