Skip to content

Troubleshooting steps for ycmd server SHUT DOWN

Ben Jackson edited this page Jul 9, 2020 · 7 revisions

This page is for anyone getting the following or similar variant on Vim startup

The ycmd server SHUT DOWN (restart with :YcmRestartServer). Unexpected exit code 1. Type ':YcmToggleLogs ycmd_57346_stderr_2hrqlh43.log' to check the logs.

Usually, after you check the log file it points to, you find it's empty. Sometimes the exit code is different, but basically you followed the install guide correctly, but something isn't working.

You might have googled the error and found responses from many years ago that are all not relevant. Ignore them!

Explanation

This means that we were not able to start the ycmd server. It's usually trivial to fix.

Troubleshooting

Try rebuild

It could be that the YCM core library needs to be rebuilt. This can happen if:

  • Your python version has changed
  • You recently upgraded your OS
  • etc.

This frequently happens on macOS after a brew upgrade for example.

So, first, try re-running install.py using your normal arguments (see README).

If you used the "Full" installation guide

We don't recommend using the "full" installation guide. install.py is almost always a better option as it is quicker, safer, and better supported.

If you previously used the "full" installation guide, then we recommend switching to install.py for almost all use-cases.

If you needed to build libclang from source, then, we still recommend using install.py:

$ EXTRA_CMAKE_ARGS='-DPATH_TO_LLVM_ROOT=/path/to/your/llvm' ./install.py
--system-libclang ...

If you need to get through a corporate proxy, that's possible too: here's an example.

Check that ycmd can start manually

The best way to validate installation is to try and start ycmd manually using the process that YouCompleteMe will use.

Do this:

$ cd /path/to/YouCompleteMe/third_party/ycmd/
$ cat PYTHON_USED_DURING_BUILDING
/some/path/to/python3
$ cp ycmd/default_settings.json .
$ /some/path/to/python3 ycmd --options_file=default_settings.json
serving on http://localhost:<some port>

If this appears to work, then you probably have g:ycm_server_python_interpreter set, remove that from your vimrc and retry.

Otherwise, check output, it should say something about why it wasn't possible to start up ycmd. (The serving on... output is what you should see if everything works.)

Common errors include:

Error like Possible Cause Solution
cannot find module .... Not updating the submodules git submodule update --init --recursive
segmantation fault Use of anaconda don't use anaconda when building ycmd
cannot find module ..., segmentation fault, etc. Not having rebuilt (or built) ycm e.g. python3 install.py --all. See README
No error Using the wrong python to run ycmd don't set g:ycm_server_python_interpreter, let YCM work it out
Others An incompatible or broken python environment Fix your python environment
cannot find symbol ....so Running an OS that's not compatible with pre-built libclang or clangd (e.g. RHEL 6, Ubuntu 14.04) Build clangd or libclang from source

Check YCM installation

Finally, in vim, check :filter youcompleteme scriptnames. Ensure that you only see entries for the correct locations:

  • /path/to/YCM/plugin/youcompleteme.vim
  • /path/to/YCM/autoload/youcompleteme.vim

Try with the minimal vimrc

Instructions in CONTRIBUTING.md

In short, test with vim -Nu /path/to/YCM/vimrc_ycm_minimal.

Try with one of the minimal test projects

There are example projects that are used by our test cases in /path/to/YCM/third_party/ycmd/ycmd/tests/<language>/testdata. Try to see if you get reasonable results when loading one of the test files in there, and using the minimal vimrc. This rules out your project and your vim config.