I kept reading about how great the code completion is using a vim plug-in called YouCompleteMe, so I decided to install it. I have up to now resisted using one of the vim plug-in managers. I have managed my plug ins manually using VimBalls and resisted using plug-in managers like Pathogen or Vundle. I attempted to install and use YouCompleteMe without using Vundle as YouCompleteMe recommends. I ran into problems namely Error detected while processing function youcompleteme#Enable..<SNR>nnn_SetUpPython:.
I performed an internet search for the error and found a limited number of hits most of which suggested that the problem was related to Python. I first removed my installed plug ins and re-installed them using Vundle to rule out any potential for issues caused by circumventing the recommended install method.
The issue continued to persist. Further investigation, reinforced my suspicions that the problem lay with my system’s python installation, specifically an issue with versioning.
Mac OS X has for a while now come with several versions of python available. On 10.9 Mavericks, the default version is Python 2.7.5. I am using the pre-compiled MacVim binary which compiled against the system libraries. I am also using a package management system called Homebrew. Several of the open source software packages which I have installed, but rarely use, had a dependency on a more recent version of python than is installed on Mac OS X.
Looking through the output log produced when compiling the YouCompleteMe code, I discovered that 1) the make program was finding the python interpreter version 2.6.8 not version 2.7.5 nor 2.7.8, 2) it was further locating the python packages location used by version 2.7.8 of the interpreter, and 3) linking its executable code against the default system python library for version 2.7.5.
While attempting to test another plug-in reliant on python, I found that it
also generated error messages which were cleared away by setting the
environment variable to python package location for the default system python.
Eventually, I discovered a means of causing cmake to generate makefiles
for building YouCompleteMe against the default system python which is the one
against which MacVim is built. One needs to set the
-DPYTHON_EXECUTABLE:FILEPATH=/path/to/python to the cmake program
when building. I rebuilt the YouCompleteMe plug-in yet again. Vim opened
without error but python interpreter version 2.7.8 crashed during startup.
At this point, I knew the solution was to remove the Homebrew installed version
of python from the front of the executable path. I accomplished this by running
Homebrew with the option unlink
$ brew unlink python
which removed the aliases to the homebrew python binary from the path. I will have to remember now to re-link the python install if I need to use one of the tools dependent on it. I will also need to remember to unlink the next time I run upgrade on the homebrew install.
I now have YouCompleteMe working with MacVim.
© 2014 David P Henderson. Some rights reserved.