Zulip Chat Archive

Stream: lean4

Topic: Stop server in VSCode?


Mac (May 03 2021 at 19:01):

Is there a way to stop the Lean server altogether in VS Code? When rebuilding the Lean sources in VS Code, the build can fail because the previously built Lean is already running in as the Lean server for VS Code (and thus it can't overwrite the executable). Thus, if I could start the server before building and then start it again after, I could get around this issue.

Mario Carneiro (May 03 2021 at 19:02):

Does the server build the executable? I would have assumed not

Sebastian Ullrich (May 03 2021 at 19:17):

Wow, I assume you're on Windows?

Gabriel Ebner (May 03 2021 at 19:29):

See also this change in Lean 3: https://github.com/leanprover-community/lean/commit/667e1e138162ef6d65a2041abfe760a7aa79c2c5

Mac (May 03 2021 at 20:00):

Sebastian Ullrich said:

Wow, I assume you're on Windows?

Yep, I'm on Windows.

Sebastian Ullrich (May 03 2021 at 20:15):

Ok, then we should use something like the commit linked by Gabriel so that the server doesn't have to be stopped at all

Mac (May 03 2021 at 20:31):

Sounds great! That would be even more convient!

Sebastian Ullrich (May 03 2021 at 20:38):

If anyone wants to figure this out and test it, please go ahead :big_smile:

Mac (May 14 2021 at 15:59):

Fyi, in addition to this problem appearing while building a new Lean while the server is running, it also appears if one runs elan update on a toolchain while the toolchain server is running.

Mac (May 14 2021 at 15:59):

That is, the issue is also (Lean 4) user-facing in addition to (Lean 4) developer-facing.

Aaron Liu (Jun 28 2025 at 23:20):

Is there a way to stop the server in VSCode? When I'm actively editing a file and I don't want to see the infoview or anything, the server is still running, and that slows down other stuff I want to happen (like replacing \a with α). I'd be great if I could just stop the server while I'm editing and resume it once I'm done. The "pause" button in the infoview only seems to pause the infoview state, it doesn't actually stop the server.

Kevin Buzzard (Jun 28 2025 at 23:51):

I just type killall lean in a terminal

Aaron Liu (Jun 28 2025 at 23:52):

I'm on windows sometimes and stop-process -name "lean" is more characters than I want to type.

Aaron Liu (Jun 28 2025 at 23:52):

Also I have to start it up again when I'm done typing

Aaron Liu (Jun 28 2025 at 23:52):

I'd be great if I could just use a keyboard shortcut or something

Kevin Buzzard (Jun 28 2025 at 23:58):

To start it again I just click the "lean has stopped, click here to start it again" button

Aaron Liu (Jun 29 2025 at 00:23):

Kevin Buzzard said:

To start it again I just click the "lean has stopped, click here to start it again" button

That's two more clicks than I want, and that still doesn't solve the problem with stopping Lean.

Michael Stoll (Jun 29 2025 at 09:38):

Maybe a nearly ideal solution would be to pause the server while typing (i.e., have a configurable time interval that the server waits after the user has typed something that is restarted with every keystroke). This way, one does not have to always click/type twice (to stop and then restart the server) in addition to the actual typing.

Michael Stoll (Jun 29 2025 at 09:52):

And maybe all threads the server is running should be killed when I type something.

Sebastian Ullrich (Jun 29 2025 at 09:57):

Any significant computation outliving a text edit is a bug and should be reported

Michael Stoll (Jun 29 2025 at 11:09):

My impression is that this is happening all the time. At least, I experience that VSCode becomes sluggish when typing in a (not very short) file; for example (as mentioned above), after typing \N or similar, it takes a while until appears, and in some cases, it even doesn't, and I have to delete \N and re-type it.

Yaël Dillies (Jun 29 2025 at 11:30):

That sounds a lot like what I reported months ago

Kevin Buzzard (Jun 29 2025 at 12:40):

I don't think I have ever experienced this. What OS are you on and how much memory do you have? When I am killing the server it's for reasons such as "I am running lake exe cache get or lake build on the command line and my gut feeling is that it's safer to restart" rather than "I am having problems"

Yaël Dillies (Jun 29 2025 at 12:42):

cf #general > v4.19.0-rc2 @ 💬

Michael Stoll (Jun 29 2025 at 13:00):

I'm on Linux and have a reasonably fast laptop. When I type near the beginning of a Lean file with ~500 lines or so, I can see yellow bars all the way down while typing, and the system monitor shows that the server spawns a whole bunch of threads. Depending on the situation, this can max out the number of available cores, which is when I experience the sluggishness mentioned above.

I would argue that while I'm typing, there is no need for the server to check all subsequent code in the file; this can be done once I have stopped typing (for something like maybe half a second), as it is pretty unlikely that the intermediate states of the text while I'm typing are in any way meaningful.

Robin Carlier (Jun 29 2025 at 13:09):

I asked something similar but for neovim here
It looks like for now there's no good way of doing this.

Kevin Buzzard (Jun 29 2025 at 13:50):

Oh interesting! My workflow is different -- I always dump an #exit after the declaration I'm working on if I'm hacking in the middle of a file.

Justin Asher (Jun 29 2025 at 14:20):

Michael Stoll said:

I would argue that while I'm typing, there is no need for the server to check all subsequent code in the file; this can be done once I have stopped typing (for something like maybe half a second), as it is pretty unlikely that the intermediate states of the text while I'm typing are in any way meaningful.

This is fairly standard for search engines. Does the LSP not do this?

Michael Stoll (Jun 29 2025 at 14:27):

Kevin Buzzard said:

Oh interesting! My workflow is different -- I always dump an #exit after the declaration I'm working on if I'm hacking in the middle of a file.

I resort to that when it gets too bad, but it would be better if that weren't necessary.

Kevin Buzzard (Jun 29 2025 at 14:28):

I feel like it's cruel to keep making the server try and make sense of code which is temporarily junk because there's a declaration missing (as it's being refactored or whatever) :-)

Aaron Liu (Jun 29 2025 at 14:50):

Michael Stoll said:

Maybe a nearly ideal solution would be to pause the server while typing (i.e., have a configurable time interval that the server waits after the user has typed something that is restarted with every keystroke).

I'm pretty sure this already exists, but my typing times vary and I don't want to have to wait 10 seconds for the server to restart after I'm done typing and I also don't want the server to start up again while I'm in a 10 second pause to figure out what to type next

Justin Asher (Jun 29 2025 at 16:18):

@Aaron Liu Do you want a stop / run button then that appears on the LSP console? I do not think that should be very hard to add.


Last updated: Dec 20 2025 at 21:32 UTC