lualine.nvim icon indicating copy to clipboard operation
lualine.nvim copied to clipboard

Bug: Lualine throws error E903 when opening too many files in tabs

Open rensftw opened this issue 2 years ago • 13 comments

Versions

  • neovim: v0.7.0
  • lualine: latest
  • fugitive: latest
  • git: v2.36.1

How to reproduce the problem

Method 1: Open many files (like 40 for example) in buffers and run :bufdo tabnew

OR

Method 2: Checkout a git branch that has modified over 22 files and run:Git difftool -y main

Either way will reproduce the issue.

Expected behaviour

All tabs are opened and no errors are thrown

Actual behaviour

Neovim is able to open only 22 tabs and the following error gets thrown:

Error detected while processing BufEnter Autocommands for "*":
E5108: Error executing lua Vim:E903: Process failed to start: too many open files: 
"/opt/homebrew/bin/git"^@stack traceback:^@^I[C]: 
in function 'jobstart'^@^I...pack/packer/start/lualine.nvim/lua/lualine/utils/job.lua:9: 
in function 'start'^@^I...rt/lualine.nvim/lua/lualine/components/diff/git_diff.lua:133: 
in function 'update_git_diff'^@^I...rt/lualine.nvim/lua/lualine/components/diff/git_diff.lua:121: 
in function 'update_diff_args'^@^I[string ":lua"]:1: in main chunk
image image

Weirdly, 22 seems to be the hard cap for this issue. The only requirements to reproduce: lualine is setup and there are over 22 diffs.

Minimal config to reproduce the issue

Config

require('lualine').setup {
    extensions = {
        'fugitive', -- optional, issue is reproducible even without this line
    },
}

Additional info

  • When I open multiple tabs with nvim -p $(fzf) the issue does not happen.
  • When I open multiple buffers and then run :bufdo tabnew the error appears!
  • The error appears regardless of whether or not the directory is initialized as a git folder.

Seem like this is a key part of the issue: BufEnter Autocommands for "*"

rensftw avatar Jun 01 '22 16:06 rensftw

It feels like we are hitting process/file limit of your system . When new buffers are created we launch a git process to get diff status of associated file. Not sure how to fix it. For now if you have any other plugin that provides git diff like gitsigns you can use source option as shown here, so lualine uses information for there directly

shadmansaleh avatar Jun 08 '22 11:06 shadmansaleh

@shadmansaleh Thank you! I do also have gitsigns.nvim and using it as the diff source for lualine fixes my issue. 🎉

Keeping the issue open for now because it would persist for users without an alternative git diff source.

rensftw avatar Jun 08 '22 13:06 rensftw

Oops, I accidentally closed it 😅

rensftw avatar Jun 08 '22 13:06 rensftw

hitting the same problem. it essentially prevents me from dong anything 'interesting' on many buffers at once.

don't even have to open tabs. it fails with something as simple as bufdo e. all it does is re-reads files from disk, one after the other. it fails after about 30-40 files.

now.. that limit does indeed seem a bit low, and I'm sure it can be increased somewhere.

but we are ignoring the elephant in the room. why lualine even tries to do anything for buffers that are not attached to the current window? that's a big waste of resources in my opinion. maybe switch from BufEnter to BufWinEnter?

vitaly avatar Sep 25 '22 00:09 vitaly

actually tried changing to BufWinEnter, and it didn't help. not sure why ;) looks like bufdo does attach the buffers to the window just without actually showing it in the ui. may be ui is suspended during mass edit operations. I wander if lualine should also stop updating in those cases. it really makes no sense to update git info about tons of buffers that are not shown ...

vitaly avatar Sep 25 '22 00:09 vitaly

Maybe this may help you guys

https://gist.github.com/tombigel/d503800a282fcadbee14b537735d202c

MartianGreed avatar Dec 06 '22 13:12 MartianGreed

截屏2023-06-21 11 50 55

  1. use telescope grep to send all files into quickfix list.
  2. run cdo s/foo/bar

This error happened.

towry avatar Jun 21 '23 04:06 towry