Youcompleteme: "ycmd server SHUTDOWN" error on macOS High Sierra

Created on 14 Jan 2018  路  12Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's CONTRIBUTING document.
  • [x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • [x] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

I tried to install YCM following Full Installation Guide. I installed Vim 8 via Homebrew. Downloaded libclang 5.0.1 from official website. While compiling ycm_core, It only complained that some boost parts didn't have symbols.

Vim prompted me that The ycmd server SHUT DOWN . I tried to restart the server and got error code 6 back. I tried to resintall vim with python2 and python3, same issue.

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan  8 2018 13:58:05)
macOS version
Included patches: 1-1400
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    -gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python            +vreplace
+conceal           +linebreak         -python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               +ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.5.0 -lobjc

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /var/folders/ql/2ll14qws1h95pc9ddfxs28z00000gn/T/ycm_0dawUp.log
-- Server errored, no debug info from server
-- Server running at: http://127.0.0.1:55460
-- Server process ID: 20539
-- Server logfiles:
--   /var/folders/ql/2ll14qws1h95pc9ddfxs28z00000gn/T/ycmd_55460_stdout_AScDRH.log
--   /var/folders/ql/2ll14qws1h95pc9ddfxs28z00000gn/T/ycmd_55460_stderr_fBz0CT.log

Contents of YCM, ycmd and completion engine logfiles

Client Logfiles:

2018-01-13 18:00:15,620 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 236, in CheckIfServerIsReady
    'ready' )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=55460): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x10a964d50>: Failed to establish a new connection: [Errno 61] Connection refused',))
2018-01-13 18:00:15,728 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 236, in CheckIfServerIsReady
    'ready' )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 69, in GetDataFromHandler
    timeout ) )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=55460): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x10a964790>: Failed to establish a new connection: [Errno 61] Connection refused',))
2018-01-13 18:00:15,832 - ERROR - The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -6. Type ':YcmToggleLogs ycmd_55460_stderr_fBz0CT.log' to check the logs.
2018-01-13 18:00:20,074 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 223, in HandleServerException
    yield
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/debug_info_request.py", line 41, in Start
    self._response = self.PostDataToHandler( request_data, 'debug_info' )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 79, in PostDataToHandler
    timeout ) )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 189, in JsonFromFuture
    response = future.result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=55460): Max retries exceeded with url: /debug_info (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x10a9a4450>: Failed to establish a new connection: [Errno 61] Connection refused',))

Both server log files are empty.

OS version, distribution, etc.

macOS High Sierra 10.13.2

Output of build/install commands

cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/clang . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

output

cmake --build . --target ycm_core

output

Most helpful comment

Build YCM with the install.py script:

./install.py --clang-completer

and try again.

All 12 comments

The server crashed before creating the logfiles. Could you run the following commands in a terminal:

cd ~/.vim/bundle/YouCompleteMe/third/ycmd
cp ycmd/default_settings.json .
python ycmd --options_file default_settings.json

and paste the output?

@micbou it seems it's running and the output is:

serving on http://127.0.0.1:56573

I noticed that if I ran it again, default_settings.json would be deleted automatically, thus gave me error like this. Is this expected?

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 196, in <module>
    Main()
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 156, in Main
    options, hmac_secret = SetupOptions( args.options_file )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 133, in SetupOptions
    user_options = json.loads( ReadFile( options_file ) )
  File "/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/utils.py", line 58, in ReadFile
    with open( filepath, encoding = 'utf8' ) as f:
IOError: [Errno 2] No such file or directory: 'default_settings.json'

I noticed that if I ran it again, default_settings.json will be deleted automatically, thus give me error like this. Is this normal?

Yes, the server automatically deletes that file on startup. That's why we are copying default_settings.json before starting the server.

I think you are experiencing the issue described in that FAQ entry except that you don't see the error because there are no logs. What's the output of

otool -L ~/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so

?

@micbou the output is

/Users/Gosin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so:
    @rpath/ycm_core.so (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
    @loader_path/libclang.dylib (compatibility version 1.0.0, current version 5.0.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

@micbou Sorry, I'm not clear about the FAQ entry. Should I build libpython separately?

Build YCM with the install.py script:

./install.py --clang-completer

and try again.

@micbou it worked. Thanks a lot. Could you please explain what's the issue here?

Your ycm_core.so was linked to the static version of Python library instead of the dynamic one; causing the server to crash with the error Fatal Python error: PyThreadState_Get: no current thread (which apparently exit the process with the status code -6). The install.py script makes sure that ycm_core.so is dynamically linked to the Python library.

This error drove me batty. Here is my solution (My case might only involve a small subclass of users but if they are on macs they might be running MAMP).

I was running MAMP and that had its own version of python. I had to point my path to MAMP apache and MySQL and that is what made python point to the wrong version of python. I removed MAMP from my paths, refreshed the terminal and then ran

./install.py --clang-completer

Make sure you are inside the ycm plugin folder. After running it, all was right with the universe again.

Blame it on the MAMP

For posterity, the following worked for me when remedying the following error:

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

Here are my installation steps:

  1. Add YouCompleteMe to your .vimrc:
Plugin 'Valloric/YouCompleteMe'
  1. Install plugins via the command-line:
vim +PluginInstall +qall

Alternatively, use :PluginInstall within Vim.

  1. Update git submodules:
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive
  1. Install cmake via Homebrew:
brew update && brew upgrade || brew install cmake
  1. Set PYTHON_CONFIGURE_OPTS environment variable:
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.14

Reference

  1. Install YouCompleteMe using the system Python binary:
/usr/bin/python ~/.vim/bundle/YouCompleteMe/install.py

I have python3.7 running via conda
so needed to invoke the system python as mentioned by @NickolasHKraus
/usr/bin/python install.py

I encountered a similar issue:

The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -11.

I needed to re-install with python3.

Running

python ycmd --options_file default_settings.json

would not yield any output, and running

python3 ycmd --options_file default_settings.json
Segmentation fault: 11

showed a segmentation fault.

Running

python3 ./install.py --clangd-completer --rust-completer --go-completer

Fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings