lsp-mode prompts if pyls should be restarted on emacs exit

Created on 7 Feb 2019  路  16Comments  路  Source: emacs-lsp/lsp-mode

Describe the bug
When editing a python buffer using lsp-mode with the pyls language server, emacs will prompt to restart pyls on exit.

To Reproduce
Steps to reproduce the behavior:

  1. Open a buffer python buffer (lsp is called through mode hook)
  2. Exit emacs using C-x C-c
  3. Emacs will show a prompt in the minibuffer: Server pyls:xxxx exited with status signal. Do you want to restart it? (y or n)

Expected behavior
Emacs should exit and kill any active language servers without any prompts.

Which Language Server did you use
pyls

OS
Fedora 29

bug enhancement minor

Most helpful comment

you may workaround the issue using the following setting:

(setq lsp-restart 'ignore)

Please, let me know whether it works for you.

All 16 comments

you may workaround the issue using the following setting:

(setq lsp-restart 'ignore)

Please, let me know whether it works for you.

Thanks, it seems to be working for me.

It happened to me with lsp for javascript and go.

(setq lsp-restart 'auto-restart) works, too, and it may prevent disconnection while working under high cpu-loads.

@yyoncho This workaround defeats the purpose of the interactive option. Can't you set a hook in kill-emacs-hook to disable the restart prompt?

@jimmywongroo we do that - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L2201 and the issue does not reproduce with emacs -q . IMO some third-party package is triggering it but it requires more investigation.

The problem seems to be the workspace' shutdown-action is nil when the sentinel is invoked. The package that's causing this is exec-path-from-shell. Any ideas why changing the exec-path will cause this behavior?

got same error, for my config , i found the reason that i installed use-package server. if i remove it , works well. so maybe this informaition can help you

@taigacute , thank you - can you test whether the following snippet will fix the issue (it should be executed after lsp-mode and server package are loaded:

(setq  kill-emacs-hook (cons 'lsp--global-teardown (delete 'lsp--global-teardown kill-emacs-hook)))

@yyoncho hi it can work. i add here https://github.com/hardcoreplayers/hardcoremacs/blob/master/core/core-general.el#L93

i think it not load after lsp-mode . bu it can work

Thank you, then something like this should be able to fix the issue:

(with-eval-after-load 'server
  (setq  kill-emacs-hook (cons 'lsp--global-teardown (delete 'lsp--global-teardown kill-emacs-hook))))

This will make sure that the lsp-mode kill hook is executed before server hook trying to kill the buffers.

Thank you, then something like this should be able to fix the issue:

(with-eval-after-load 'server
  (setq  kill-emacs-hook (cons 'lsp--global-teardown (delete 'lsp--global-teardown kill-emacs-hook))))

This will make sure that the lsp-mode kill hook is executed before server hook trying to kill the buffers

i have add these code,but doesnt work, maybe i add it in a wrong postion, where should i add it .

Can you tell me what is the value of kill-emacs-hook before you kill emacs and the issue reproduces?

Its value is
(treemacs--persist bookmark-exit-hook-internal amx-save-to-file prescient--save company-clang-set-prefix save-place-kill-emacs-hook org-babel-remove-temporary-directory lsp--global-teardown desktop-kill recentf-save-list flycheck-global-teardown ido-kill-emacs-hook server-force-stop)

yes, its reproduce

What happens if you eval the block just before killing emacs?

(with-eval-after-load 'server
  (setq  kill-emacs-hook (cons 'lsp--global-teardown (delete 'lsp--global-teardown kill-emacs-hook))))

prompt the gopls restart y-or n

This has to do with https://github.com/emacs-lsp/lsp-mode/issues/641#issuecomment-495744002

I suspect anything that touches exec-path such as add-node-modules-path and exec-path-from-shell will cause this bug.

Was this page helpful?
0 / 5 - 0 ratings