0

I was happily editing along when I tried to save and Neovim gave me this error "can't open file for writing, too many files" and overriding with ! did not help. I decided because it had not been too long since last time I had successfully saved, I would simply quit, then reopen the file. Upon quitting, I discovered to my horror that the file was no longer present, and its .swp file was also not in ~/.local/share/nvim/swap although others were there. I've been unsuccessful at recovering the file and am starting over with my project. But, what happened here and how do I prevent it? Yes, I could commit to my repo more often. I had 1 browser open, and 6 buffers open in neovim, and entr was my task runner. I also tried nvim -r <file> but because the swp file is missing, it does nothing.

EDIT1:

  • The path to my file was ~/projects/test/plet.nim
  • The dir test had fewer than 40 files.
  • entr was watching only my 1 file plet.nim using the following invocation:

ls plet.nim | entr -c bash -c "<compile command> && <run command>"

4
  • 2
    Provide the directory structure of the files. "Can't open file for writing" happens mainly when there is a directory in the filename that doesn't exist, and since vim can't create intervening directories, it can't create the file which exists in the intervening directories. We need to know if this is the case you're facing.
    – 3N4N
    Commented Nov 3, 2022 at 5:30
  • 1
    Too many files is probably an OS-level error: you might have run out of file descriptors. This can happen when using entr with lots of files.
    – D. Ben Knoble
    Commented Nov 3, 2022 at 13:56
  • @3N4N, I've added what I think you are asking for in EDIT1
    – GGibson
    Commented Nov 4, 2022 at 17:18
  • @D.BenKnoble, interesting - I've added my entr command in EDIT1. Do you see something bad practice here? Is it that entr can get itself into a bad state even when only working with 1 file?
    – GGibson
    Commented Nov 4, 2022 at 17:18

1 Answer 1

1

Probably the answer is that this was the fault of entr somehow having many file descriptors open, thus causing OS problems. I have not had issues since stopping using entr. Thanks to D. Ben Knoble for the suggestion.

1
  • 1
    You can usually increase the limit for this; the details for this depend on the system you're using. Commented Nov 15, 2022 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.