nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.71k stars 455 forks source link

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

Open rensftw opened 2 years ago

rensftw commented 2 years ago

Versions

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

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

shadmansaleh commented 2 years ago

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

rensftw commented 2 years ago

@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 commented 2 years ago

Oops, I accidentally closed it πŸ˜…

vitaly commented 1 year ago

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 commented 1 year ago

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 ...

MartianGreed commented 1 year ago

Maybe this may help you guys

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

towry commented 1 year ago

ζˆͺ屏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.

Sleepful commented 1 week ago

for me it was the branchname on display in the lualine, so I added an external source:

https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets#using-external-source-for-branch

Sleepful commented 1 week ago

My previous comment didn't seem to fix it.... whenever I am saving a file after working for a while, I am getting the following:

Error detected while processing BufWritePost Autocommands for "*":
E5108: Error executing lua Vim:E903: Process failed to start: too many open files: "/usr/bin/git"
stack traceback:
        [C]: in function 'jobstart'
        ...l/share/nvim/lazy/lualine.nvim/lua/lualine/utils/job.lua:9: in function 'start'
        ...zy/lualine.nvim/lua/lualine/components/diff/git_diff.lua:133: in function 'update_git_diff'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue
Sleepful commented 1 week ago

Now I am trying to use ulimit -n 10240 per https://github.com/neovim/neovim/issues/14192