Replies: 35 comments 11 replies
-
When creating this issue, did the following text appear in front of you?
|
Beta Was this translation helpful? Give feedback.
-
And I am guessing too, because I don't have an MRE. Maybe Eglot could be taught by the user not to watch certain folder with very large contents, or maybe you need to explain what the structure of your project and use |
Beta Was this translation helpful? Give feedback.
-
Is this MRE? The LSP mode has this solution for the same problem. |
Beta Was this translation helpful? Give feedback.
-
By golly man, did you read that link yourself? Yeah I know I did not give all that was asked (because I was confused myself) at first but what from that link in the red box is missing from the screenshot I responded with? mkdir mre
cd mre
python3 -m venv .venv
source .venv/bin/activate # maybe different depending upon the OS
pip3 install pyright numpy numpydoc
emacs test.py -Q -f toggle-debug-on-error -f eglot Does this not replicate the issue for you?
Does not look like it. I thought Emacs community was friendlier to the first time bug reporters, maybe the Node under the Pyright's hood is rubbing off. |
Beta Was this translation helpful? Give feedback.
-
Not only did I read it, I wrote it. Because I don't want to write it every time I am faced with a similar difficulties.
I'm sorry you find this unfriendly. All the times it takes to you to read the information I wrote is negligible to the effort I put in writing it again and again and guessing your setup. Many other projects take a similar stance. See for example this link where I modelled some of Eglot's bug reporting practice. If this seem unfriendly to you, you should try put yourself in the shoes of a a single unpaid software maintainer of a popular package dealing with many bug reports (and still trying to have a dayjob and a non-programming-related life).
Sigh. I won't even lose time trying it until you specify what |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Yes, it usually does. Emacs and Eglot exhibit different behaviour depending on the contents of the file.
Sorry, that was in the beginning of the issue. I'd rather have a compact MRE where I don't have to scroll up and forth. You could also use
Please put in the work for following the isntructions to supply a good bug report. If you don't want to put this time, you can informally report a problem in the discussions instead. This is also stated in the text that you skipped. |
Beta Was this translation helpful? Give feedback.
-
I don't see a form that I can fill out and I think being handed a shell script that literally produces the backtrace is a good bug report. I have read your instructions like 3 times and IDK what else do you want.
IDK how that clears things up any further.
mkdir mre
cd mre
python3 -m venv .venv
source .venv/bin/activate # maybe different depending upon the OS
pip3 install pyright numpy numpydoc
emacs test.py -Q -f toggle-debug-on-error -f eglot What else do you want!? Honestly, forget about it if you still don't have everything you need. |
Beta Was this translation helpful? Give feedback.
-
I think I have everything, thanks.
I'm on Linux and installing all this stuff will have to be done in a container possibly, but I should find time to look at it this week. |
Beta Was this translation helpful? Give feedback.
-
The If you are on Linux, likely Python 3 is installed, if it is, then Pip is installed as well. You don't need anything else. The command, |
Beta Was this translation helpful? Give feedback.
-
Can't reproduce on linux. Googling brought me here: https://www.reddit.com/r/emacs/comments/x4p7mg/fix_annoying_max_open_files_for_emacs/ You could also try explaining to |
Beta Was this translation helpful? Give feedback.
-
@simurgh9 when this LSP provider was added to elgot it supposed to use https://github.com/microsoft/pyright, please try to install it via npm or yarn: |
Beta Was this translation helpful? Give feedback.
-
@illia-danko thanks, but I don't know if that will make a difference. I think the main problem here is that Pyright tries to watch too many files. Specifically, the files under This isn't a real problem on Linux because watching a directory with many files doesn't require many file descriptors. On MacOSX, it does and there aren't usually enough of them. What I meant by "explaining to pyright that we don't want the contents of the full hidden .venv directory watched" is that maybe there is a Pyright command-line option to achieve that. Or maybe a ticket should be raised with the server to request this. Eglot could also add code to stop watching |
Beta Was this translation helpful? Give feedback.
-
BTW just to avoid any miscommunication, I don't think I am on MacOS X. If I understand correctly, that is MacOS 10, (X being a roman numeral). I am on MacOS Venture 13.3.1. |
Beta Was this translation helpful? Give feedback.
-
Force of habit., sorry. They dropped the X some years ago. I last used used MacOS in those versions (when it was a half-decent OS). Doesn't make a difference I think |
Beta Was this translation helpful? Give feedback.
-
After analysing this and seeing there's little intention to change things over at Pyright, I can recommend the following fixes:
The latter solution seems to be much easier
You'll lose some file-watching capabilities in |
Beta Was this translation helpful? Give feedback.
-
Also converting this to a discussion which is what it should have been in the first place. |
Beta Was this translation helpful? Give feedback.
-
I don't usually use project.el, e.g., if I really just wanna get completions in a single Python script within a virtual environment, saying that it needs to be within a project sounds like a reason I pick Emacs over any IDEs.
What side effects would that have? Does that mean I no longer get features that require watches, e.g., completions? Also, why do we not have the same issue of excessive file watches when the project structure is like this,
Instead of,
|
Beta Was this translation helpful? Give feedback.
-
If you use Eglot, you use project.el automatically. LSP requires the idea of a project, or rather a workspace. There's no escaping that.
I don't think so but that's something you should test yourself and/or ask the author of the language server.
Possibly because in the absence of a But just guessing. more categorical statements about specific cases need their own MREs (Your current MRE didn't specify Git usage) |
Beta Was this translation helpful? Give feedback.
-
I suppose but it does not need a git repo. So somehow Eglot figures out the workspace root.
Can we not make sure the mechanism that finds the project root without a |
Beta Was this translation helpful? Give feedback.
-
Yes, Unfortunately, to get the
You should read |
Beta Was this translation helpful? Give feedback.
-
I also ran into this issue with large Python Pandas libraries and Pyright last week. I 100% agree with entire discussion above about bumping OS file limits, excluding files with project configs, etc. However, in troubleshooting I did find a few other things. I noticed that Pyright (maybe happens with other LSP's) watcher flow is:
There is a good discussion in this section of LSP spec talking about some of efficiencies that clients can do. One such thing is to share the same file descriptors across these two watchers. This should make more efficient than taxing system with (thousands?) of duplicate file notifiers. Another thing I noticed, once file limit was hit, the server just failed - making difficult to see what is happening. It would be great to have Lastly, I noticed that when notified of a new directory created, it should also have a file notifier added. I submitted a PR #1228 for these changes. I understand since Eglot is now part of Emacs, this is not the right way. But I wanted to have it handy for this discussion, and if you feel good about it I can submit paperwork, etc. Lastly, not related to PR, but to the discussion about file limits. This was still failing even though my file limits are large. The problem is related to Emacs on Mac (maybe others) that puts limit at |
Beta Was this translation helpful? Give feedback.
-
Nonwithstanding that your optimization proposal for Eglot is interesting, this would seem completely misguided from Pyright. Do you have any idea why Pyright does it like this? Pyright already sends a |
Beta Was this translation helpful? Give feedback.
-
I was going to research that more, I don't know specifically yet. But if I were to guess, Pyright (maybe others) probably does this because client/server are initializing, which maybe running builds, etc. that could impact what is being watched. Based on monitoring changes in vscode for pyright, pyright is pretty aggressive on monitoring files. Seems all of the cross-platform IDE's struggle with the file watchers. Like: https://github.com/microsoft/vscode/wiki/File-Watcher-Issues or https://emacs-lsp.github.io/lsp-mode/page/file-watchers/ . The benefit about the patch I submitted, there is a lot less resources spent adding and removing watches - since only adds/removes the changes. One thing I did just come across, if create a directory via It may make sense to exclude things like |
Beta Was this translation helpful? Give feedback.
-
OK, I understand this is just a guess/conjecture. But it doesn't make sense to me. Why not just start watching when all those hypothesized builds are done? As far as I understand it is this hitherto unjustified behaviour which is at the heart of the motivation for your optimization in PR #1228, which -- interesting and presumably correct as it is -- does complicate what is already complicated code considerably. And I'm not sure I like that. Or at least I would like to know what Eglot is getting in return. So it is important to understand why the server behaves the way it does. My more pessimistic/cynical guess is that the server behaves like this because it can. Because no other client that the M$ folks care about uses kqueue in Mac OSX and they think VSCode is the only client and VSCode has options to ignore server-request file watches. |
Beta Was this translation helpful? Give feedback.
-
Yes, I don't disagree with anything you say. [smile]
I noticed testing And that could be the other simpler option, to just ignore the id sent by server for Regardless, of direction you decide... I do think there were a couple other trival changes in the patch that should be added in order to make debugging easier by average users (and less noise for you), such as:
I was also going to send notes to some of the maintainers of MacOS builds of emacs that they should adjust |
Beta Was this translation helpful? Give feedback.
-
Did we ever decide about what is the best way forward? |
Beta Was this translation helpful? Give feedback.
-
I understand that adding excludes similar to those seen in lsp-mode goes against the division of responsibilities envisioned for eglot. However, It doesn't take a huge repo to blow out the file-watcher limit. Even after bumping the limits and swapping It's unlikely that we will be able to get pyright to stop being so abusive with the way it watches files, and for many of us moving away from osx is impossible since we don't always control the environments we work in. Maybe it's worth adding the excludes at the expense of some kludge? |
Beta Was this translation helpful? Give feedback.
-
I am on MacOS Venture 13.3.1, GNU Emacs 30.0.50 (
brew install emacs-nightly
), Eglot 1.14 (found by looking ateglot.el
) and finally Pyright 1.1.307 (pip3 install pyright
).My issue is similar to this: #768
As soon as I run
eglot
, I get,Here is the backtrace:
And these are the event logs:
I tried googling the no file descriptors left error and found this,
Well, but I am not using
lsp-mode
but maybe something similar is happening with eglot?Any hint to a resolution is appreciated.
EDIT
Okay I've figured something out, this only happens when I run
eglot
from within a file that is in the same directory as a virtual environment folder, e.g.,.venv
. I am guessing that happens because emacs tries to create a watch for all the files in there. I am not sure what a good fix is though other than moving the.venv
away.Beta Was this translation helpful? Give feedback.
All reactions