YouCompleteMe and pyenv

Created on 5 Jan 2014  ยท  30Comments  ยท  Source: ycm-core/YouCompleteMe

I've been having considerable difficulty getting YouCompleteMe and pyenv to cooperate. I'm currently running OS X, Homebrew, MacVim (installed via Homebrew), and Python 2.7.6 through pyenv.

First, I tried uninstalling MacVim, running "pyenv global system", re-installing MacVim, then recompiling YouCompleteMe. With this setup, I get the following error:

The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 lines):

Next, I tried running "pyenv global 2.7.6", uninstall MacVim, re-installing MacVim (under the assumption my local 2.7.6 will be linked), then re-compiling YouCompleteMe. I get the following error:

Vim: Caught deadly signal ABRT

Vim: Finished.
fish: Job 1, 'vim test.py' terminated by signal SIGABRT (Abort)
                                                               โŽ

Either way, YouCompleteMe is unusable. Any ideas as to what the cause of this is?

Most helpful comment

I ended up here again, a year later -- seems things have moved on. I found that installing Python through pyenv with the flags as described in https://github.com/yyuu/pyenv/issues/65 was enough to get YCM to compile happily. I haven't yet experienced the crash I was getting before. This is what I did:

rm -rf ~/.pyenv/versions
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.3
# now run YCM install script

Let's hope my virtualenvs haven't all exploded!

All 30 comments

Please see CONTRIBUTING.md.

Not sure why this was closed as pyenv is gaining quite a bit of popularity...

Anyway, for posterity's sake, I'll share how I resolved this issue:

  1. Disable pyenv completely.
  2. Uninstall both MacVim and Python.
  3. Install MacVim (the point is to get MacVim to link against OS X's built-in Python).
  4. Re-compile YouCompleteMe.
  5. Install Homebrew's Python (if desired).

Note that this still leaves the use case of pyenv + YouCompleteMe unattainable, so again, I'm not sure why this issue was closed.

Just to follow up: looks like you can't install Homebrew's Python, as I get continual YCM errors upon start up. I wish there were some documentation on how to correctly link Homebrew's Python to work with both Vim and YCM, but until that happens, I've reverted back to using the base system Python.

Hope this helps.

Moreover, enabling a virtualenv also causes YCM to crash. Needless to say, this has been an incredibly frustrating experience as (prior to experimenting with pyenv), YCM just worked with no issues. I'm not sure what changed in my environment to cause these issues, but I've now spent more than 5 hours trying to debug this issue with no luck.

@danieljaouen I use VIM/GVIM on linux compiled for my python instance from a default virtualenv, no issues. I think I've done the same on OS X when I used it, but setup there was worst because of the way the system setup its defaults (python, gcc, clang, Xcode stuff, homebrew stuff, system stuff, and what not...)

anyway, it was not YCM fault in any situation, since I figured it out, and just need to setup the system properly.

@oblitum A YCM error other than:

The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 lines):

would be helpful, here.

And of course, restarting the server just causes it to shut down again with no additional error information.

things like these helped me set the system properly for compiling and loading correct python, etc for custom compiled MacVim... it's just a sample anyway, I tried to find other links I used but they're broken, so if needed, dig deeper.

by the way, at the time, I compiled MacVim from git repo cloned by me, not homebrew. I avoided homebrew when it was prone to cause more damage than help.

I had the same issue.
It turns out that on OSX system python does not include 'python2' command, therefore, pyenv throws this when you are calling python2 command:

jabbas@rahl ~ % python2
pyenv: python2: command not found

The `python2' command exists in these Python versions:
  2.7.6
  transmission-rss-2.7.6

and YCM server freaks out...

Fix/Workaround:

cd /usr/bin && sudo ln -s python python2

or add this to vimrc:

let g:ycm_path_to_python_interpreter = '/usr/bin/python'

I've just got back to OS X (because of Swift & Playground) and I had to make a clean install of Mavericks. As of now I have installed everything from homebrew, no problems. The only issue is that, homebrew macvim installation will use the system installed python/ruby, and if you have installed python/ruby from homebrew, then the homebrew build of macvim will use this python/ruby for the build (if you have given homebrew binaries priority over system binaries), because rbenv/pyenv instances are unrelated to the homebrew instances, and stuff built by homebrew should be dependent of homebrew stuff.

So what I've done? I've installed a recent ruby/python in homebrew to use as system instance for rbenv/pyenv. I've then installed macvim with homebrew with the rbenv/pyenv system instance as active (again, the one installed by homebrew, not rbenv/pyenv, and which have priority over the ones in /usr/bin by configuring PATH), and built YCM while in this environment setting.

I then use other pyenv/rbenv non-system instances for other stuff. There's no way to have a dynamic setting of python instances to be loaded by VIM, since this is set at compilation-time, and hence, set for YCM too.

@oblitum , Can you try the old version of it?
Don't forget to add let g:ycm_path_to_python_interpreter = '/Users/NAME/.pyenv/shims/python' to .vimrc. Good luck.

I had the same problem where a YCM compiled with Macports' python crashed when I ran it in a Virtualenv. Setting let g:ycm_path_to_python_interpreter = '/Users/NAME/.pyenv/shims/python' as suggested by @jabbas and @ldong fixed the problem for me.

On OSX Yosemite (Homebrew Python, pyenv) I installed MacVim with pyenv "off", so above didn't work. When I use let g:ycm_path_to_python_interpreter = '/usr/bin/python' things seem happier.

Nice, so I'd like to correct my statement where I said it's not possible to have a dynamic setting for YCM.

At a wild guess, YCM isn't designed to work in an environment where the Python "version" is changing all the time (it would probably be necessary to compile YCM for each virtualenv) but since the plugin doesn't need anything specific from the virtualenv (?) compiling against the OSX system Python gives it _some_ Python to use... I think it only uses Python for running the service and connecting to it. I didn't look at the source, C++ scares me.

Hello there,
according to CONTRIBUTING.md I should comment here rather than create a new issue.
Vim-Version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07)
OS: Debian-based Linux (Debian 4.0.4-1) x86_64
Python-Version: 2.7.9-1 (& python-dev)

I want to use YouCompleteMe for C (with semantic autocompletion) and golang.
I am experiencing the same error message, after I followed the full instructions step-by-step (I am NOT using the system-llvm/clang):
The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 line
s)

I dont know how to fix this, setting the python interpreter path for ycm (to /usr/bin/python) did not change anything.

@Feve2 what are those 30 lines??

I've got the same problem as Feve2, except I'm not using clang. Followed the instructions exactly, YCM loads but then crashes immediately with:
The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 lines)

No indication what the last 30 lines were. :YcmDebugInfo is no help either:
-- Server crashed, no debug info from server
-- Server running at: http://127.0.0.1:59544
-- Server process ID: 16803

Vim -Version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
OS: Ubuntu 14.04
Python-Version: 2.7.9

I'm trying to use YCM for Javascript, but it crashes in any file.

what are those 30 lines??

I'm having the same problem as @Feve2 and @GameKyuubi where I see the following error on vim soon after I go into insert mode:

The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 lines)

Press ENTER or type command to continue

And nothing else follows. Issuing :YcmDebugInfo shows the following:

Printing YouCompleteMe debug information...
-- Server crashed, no debug info from server
-- Server running at: http://127.0.0.1:50102
-- Server process ID: 57339
-- Server logfiles:
--   /var/folders/nb/nhl319m14555xy2lj0vsqjyr0000gn/T/ycm_temp/server_50102_stdout.log
--   /var/folders/nb/nhl319m14555xy2lj0vsqjyr0000gn/T/ycm_temp/server_50102_stderr.log
Press ENTER or type command to continue

cat-ing those two files show:

$ cat /var/folders/nb/nhl319m14555xy2lj0vsqjyr0000gn/T/ycm_temp/server_5
0102_stderr.log
2015-10-27 16:16:16,105 - DEBUG - No global extra conf, not calling method YcmCorePreload

$ cat /var/folders/nb/nhl319m14555xy2lj0vsqjyr0000gn/T/ycm_temp/server_5
0102_stdout.log

Vim Version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 27 2015 14:01:33)
OS: Darwin 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015
Python Version: Python 2.7.3
pyenv version: pyenv 20150913

I should add that when I compiled YCM, it was on a different python version (i.e. 2.7.10). When I work on my Ruby projects, YCM works fine. When I work on a project that uses the the same python version used during YCM install, it works fine too. When I work on a Python version that uses any other Python version (as set by the .python-version file in the project root), the error occurs. I hope that helps. Let me know if there's any other information I should provide.

You could try to point ycmd to the right python interpreter using the g:ycm_path_to_python_interpreter option.

I encountered the same problem even after doing that. It turns out that brew install macvim searches for the first python interpreter it finds and so does YCM which, I think, is different from what Homebrew finds if pyenv is already installed and there are multiple python versions. However, after doing this:

  1. Completely uninstall pyenv
  2. Restart the terminal
  3. Reinstall MacVim
  4. Reinstall YCM
  5. Set g:ycm_path_to_python_interpreter in .vimrc
  6. Reinstall pyenv

It seems to be working fine now. The second to the last step isn't very portable since I distribute my dotfiles across Mac and Linux systems but I think that's easy enough to fix.

I ended up here again, a year later -- seems things have moved on. I found that installing Python through pyenv with the flags as described in https://github.com/yyuu/pyenv/issues/65 was enough to get YCM to compile happily. I haven't yet experienced the crash I was getting before. This is what I did:

rm -rf ~/.pyenv/versions
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.3
# now run YCM install script

Let's hope my virtualenvs haven't all exploded!

I ended up here again, a year later -- seems things have moved on. I found that installing Python through pyenv with the flags as described in pyenv/pyenv#65 was enough to get YCM to compile happily. I haven't yet experienced the crash I was getting before. This is what I did:

rm -rf ~/.pyenv/versions
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.3
# now run YCM install script

Let's hope my virtualenvs haven't all exploded!

Shockingly, this still works

It's not shocking. It's mentioned in the wiki (and our CI scripts).

@bstaletic - can you point out where? I only saw export PYTHON_CONFIGURE_OPTS="--enable-framework" when I tried to install it, haven't seen anything about removing .pyenv/versions and setting enable-shared

I Googled for ycm pyenv, haven't found anything useful, except for this git issue

Was this page helpful?
0 / 5 - 0 ratings