Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YCM does not exit when vim exits #2403

Closed
gh67uyyghj opened this issue Oct 24, 2016 · 15 comments
Closed

YCM does not exit when vim exits #2403

gh67uyyghj opened this issue Oct 24, 2016 · 15 comments

Comments

@gh67uyyghj
Copy link

I am using vim 8 on Archlinux and YCM is installed using Vundle. The problem is I found that there are many python processes left running as many as the vim instances I opened and then closed. i.e. YCM doesn't gracefully exit when I quit a vim instance. I don't know if this is a bug but I really doubt this belongs to any vimrc option. I am ready to show any further details but I frankly I don't know what to show currently. I need some help in this. Thanks!

@micbou
Copy link
Collaborator

micbou commented Oct 24, 2016

Start Vim with YCM enabled and type the following command:

:py3 ycm_state.OnVimLeave()

Does it result in an error? Is the Python process still up after this command?

@l3nkz
Copy link

l3nkz commented Nov 9, 2016

I have the same problem. ycmd continues executing after vim is closed and consumes an significant amount of memory this way.

If I execute you given command, I get the following error:

Traceback (most recent call last):
   File "<string>", line 1, in <module>
NameError: name 'ycm_state' is not defined

If i execute the command with the python2 interpreter, it does not give any error message or other output but kills the ycmd server associated with this file.

@micbou
Copy link
Collaborator

micbou commented Nov 11, 2016

@l3nkz Which OS and Vim version? Is the ycmd process not terminated each time you are closing Vim or does it happen randomly?

@l3nkz
Copy link

l3nkz commented Nov 11, 2016

@micbou I use an up-to-date Arch Linux with vim 8.0 with patches 1-55. I installed YCM via vundle and update it regularly. The ycmd process is never terminated together with vim. I can reproduce it very easily.

@vheon
Copy link
Contributor

vheon commented Nov 11, 2016

The ycmd process is never terminated together with vim. I can reproduce it very easily.

But does it terminate right after or it doesn't terminate at all?

@l3nkz
Copy link

l3nkz commented Nov 11, 2016

The ycmd process is not terminated at all. I have to manually terminate it by sending SIGTERM to it. To be fair, I haven't checked if it terminates after some hours, because I am working in a VM with to little memory ;)

@micbou
Copy link
Collaborator

micbou commented Nov 11, 2016

It looks like YCM VimLeave event is not triggered when you are closing Vim. What's the output of :au VimLeave?

@l3nkz
Copy link

l3nkz commented Nov 12, 2016

This command gives the following output for me.

:au VimLeave
--- Auto-Commands ---
youcompleteme  VimLeave
    *         call s:OnVimLeave()

@micbou
Copy link
Collaborator

micbou commented Nov 14, 2016

So, YCM VimLeave autocommand is properly registered. Could you run the following command:

vim -c "autocmd VimLeave * call writefile([v:dying], 'vim_leave', 'a')" -c ":q"

in a terminal? This should create the vim_leave file in the current directory with 0 as its contents. If the file doesn't exist then it's not an issue with YCM but with Vim not triggering the VimLeave event when exiting.

@l3nkz
Copy link

l3nkz commented Nov 14, 2016

This command properly creates the vim_leave file.

@micbou
Copy link
Collaborator

micbou commented Nov 16, 2016

And what about the ycmd process?

@micbou
Copy link
Collaborator

micbou commented Nov 20, 2016

I really can't reproduce the issue on my ArchLinux VM with Vim 8.0.55. This could be a bad interaction with another plugin. Is the ycmd process still up after closing Vim when starting it with this minimal vimrc?

set nocompatible

set rtp+=~/.vim/bundle/YouComplete

filetype plugin indent on

syntax on

@l3nkz
Copy link

l3nkz commented Nov 22, 2016

Using this minimal vimrc fixed the problem for me. Thank you very much. I will dig deeper and see if I can find the plugin causing the behavior. Sorry for the noise.

@vheon
Copy link
Contributor

vheon commented Nov 22, 2016

So closing for now 😉

@vheon vheon closed this as completed Nov 22, 2016
@erahhal
Copy link

erahhal commented Dec 21, 2016

I had the same problem, and did disabled my plugins one at a time, and found that the jistr/vim-nerdtree-tabs plugin was causing the problem. It may be NeoVim specific. See:

vim-nerdtree-tabs issue 76

zzbot added a commit that referenced this issue May 15, 2017
[READY] Add FAQ entry about YCM not shutting down when quitting Vim

This issue has already been reported twice (#2403 and #2611) and is not something that we can fix on our side so we should mention it in the FAQ.

Closes #2611.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2639)
<!-- Reviewable:end -->
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants