Can't run MacVim after installing YCM
beaumartinez opened this issue · 86 comments
I installed YCM as per the instructions on the readme, and now MacVim crashes immediately after starting.
Running it in the terminal I get—
Fatal Python error: PyThreadState_Get: no current thread
Vim: Caught deadly signal ABRT
Vim: Finished.
I'm running MacVim 7.3 (snapshot 66) for OS X 10.8 (Mountain Lion), as downloaded from the official Google Code project page.
Running plain old Vim (which IIRC I brew installed), I get—
Vim: Caught deadly signal ABRT
Vim: Finished.
Abort trap: 6
When I ran :BundleInstall Valloric/YouCompleteMe
, MacVim didn't crash—but then I'm not sure if it required an reboot to fully "install".
Currently have the same problem. Followed both the cmake and make procedures which complete fine. Here is my make ycm_core
output:
I'm seeing the same here, using the version of MacVim installed and linked by homebrew
see https://gist.github.com/grncdr/4712845 for the vim -V9
and vim --version
output.
EDIT: just saw #8, I still get the same thing with the binary version of MacVim downloaded from http://code.google.com/p/macvim. I've also tried removing all plugins except vundler and YCM from my config, but I still get the same crash.
I also get the same crash with MacVim from homebrew and the binary download. I'm also using python 2.7.3 from homebrew.
Ah that's a clue. brew unlink python
and it works.
brew unlink python
and it works
So it does. Awesome find. Any insights into how that fixed things, anyone?
Incidentally, I'm not keen on having to use the system's Python—any way we can patch YMC up to make it play nice with homebrew Python?
it looks like vim uses libpython. I suspect we need it to use brew's libpython: /usr/local/Cellar/python/2.7.3/lib/libpython2.7.dylib
super hacky workaround for downloaded vim:
DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=/usr/local/Cellar/python/2.7.3/lib/libpython2.7.dylib /Applications/MacVim.app/Contents/MacOS/Vim
I personally have a script called /usr/local/bin/vim that i use to run the brew version:
I've patched my homebrew to make the MacVim build use homebrew's python, as otherwise it picked up the system python library and the homebrew python runtime and caused some strange failures in other python plugins. (https://gist.github.com/sgrankin/4719255 for the formula)
With that, I had the 'no current thread' error after installing YCM. Adding these flags to the cmake command fixed it:
-DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Python
Everything appears to agree on the python being used after that.
I have this issue too, hope something can be done about it.
Btw - if you have python installed as a framework, then you need to point to a different libpython
DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib /Applications/MacVim.app/Contents/MacOS/Vim
So, even more curious, I removed and reinstalled Homebrew's python, and now everything works fine. Can somebody else confirm?
@sgrankin additional cmake flags helped. Thanks much...
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/clang+llvm-3.2-x86_64-apple-darwin11 -DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Python . ~/.vim/bundle/YouCompleteMe/cpp
I would probably add this to the doc as many python dev's build vim/mvim using homebrew's python
@sgranking Am I correct in summarizing this thread by saying that the fix is to call brew upgrade python
?
I did not upgrade python nor reinstall vim or mvim. I just did pointed cmake to the homebrew framework dirs. (previously install brew install python --framework).
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/clang+llvm-3.2-x86_64-apple-darwin11 -DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Python . ~/.vim/bundle/YouCompleteMe/cpp
I don't use python --framework but after uninstalling python with brew and reinstalling, my next build of macvim used the system pythonlib so it is now working without modification
@Valloric More like brew rm python; brew install python
as this change happened without changing the version. And then macvim needs to be rebuild as well.
I'm closing this since it's a configuration issue and sadly not something that can be fixed on YCM's side. I've added a new FAQ item for this (that also links to this issue) and noted it in the Mac installation guide.
I think the instructions in the FAQ are insufficient as I just got done going through hell trying to figure out why after installing brewed python vim suddenly started segfaulting and it turns out to be this plugin.
The real fix here is to add the LD flags suggested earlier to the cmake command so that cmake finds the brewed version of python.
Perhaps we can add an additional flag to the install.sh script?
IMO this is a Cmake bug.
For reference, here is what I had to change with the install.sh:
function install {
ycm_dir=`pwd`
build_dir=`mktemp -d -t ycm_build.XXXX`
pushd $build_dir
cmake -G "Unix Makefiles" -DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Python $1 . $ycm_dir/cpp
make ycm_core
popd
}
Did a little more digging and it appears other brew formula have 'work arounds' in their installation scripts that YouCompleteMe could borrow from:
See:
Homebrew/legacy-homebrew#10393
Of particular interest:
https://github.com/mxcl/homebrew/blob/51d054c/Library/Formula/vtk.rb#L31-49
http://stackoverflow.com/a/12697440/1742820
Here is a workaround that works for me.
I think that the FAQ item regarding this is still not as helpful as it could be.
This isn't particular to homebrew in any way. I had python installed as a framework under /Library
(from some installer, I forget), which was the python that the ycm_core installer discovered (correctly, due to xgalaxy's python_finder
fix). However, my MacVim (which I'd compiled by hand) was using my system python. I fixed this using the symlinking hack (referenced by pencilcheck just above).
Homebrew-MacVim also uses system python (unless the user figures out how to link it against a different one, with the symlinking hack or some other way). This will likely get fixed at some point (either by a workaround in the homebrew formula or better detection by MacVim at compile time). The binary MacVim distribution, of course, always links against system python.
So as it stands, the majority of MacVim users will have a MacVim linked against system python (but some won't). Many users won't have some other python installed (but some will).
I think that it just needs to be made clear that YCM is going to compile against whatever python (and python-config, which should match) it finds in the PATH. Unless there's a way to reliably determine which python is being used by vim (and I haven't been able to figure out a reliable way... sys.version
isn't specific enough and sys.executable
outright lies sometimes), the user needs to make the call. The advice that would probably fix most people's problems when they're getting a segfault is to try putting their system python first on their PATH when compiling ycm_core.
I found the problem here is similar to the problem here.
https://bugs.launchpad.net/ultisnips/+bug/1156584
SirVer's solution of changing the python worked for me.
I've compiled YCM fine on Linux but faced this on OS X too. It's interesting that after cmake'ing, the message shows the python version to be used is the one from homebrew. Also at my machine I have ln -s /usr/local/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/Current /System/Library/Frameworks/Python.framework/Versions/Current
, so the message also tells it's using the homebrew's libpython:
> cmake -G "Unix Makefiles" -DUSE_CLANG_COMPLETER=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/addons/github-Valloric-YouCompleteMe/cpp
-- The C compiler identification is Clang 3.3.0
-- The CXX compiler identification is Clang 3.3.0
-- Check for working C compiler: /usr/local/bin/clang
-- Check for working C compiler: /usr/local/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Your C++ compiler supports C++11, compiling in that mode.
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.4", minimum required is "2.5")
Using libclang to provide semantic completion for C/C++/ObjC
Using external libclang: /usr/local/lib/libclang.dylib
-- Found PythonInterp: /usr/local/bin/python (found version "2.7.4")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/.build/ycm
After building I get this final warning:
ld: warning: path '/usr/lib/libpython2.7.dylib' following -L not a directory
To try solve the issue I've used @locojay advice:
cmake -G "Unix Makefiles" -DUSE_CLANG_COMPLETER=ON -DUSE_SYSTEM_LIBCLANG=ON -DPYTHON_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Python . ~/.vim/addons/github-Valloric-YouCompleteMe/cpp
I got the exact same output from cmake but that final warning after building changed to ld: warning: path '/usr/local/Frameworks/Python.framework/Python' following -L not a directory
. Not sure whether it's a sign of something, but at last it's working now.
@oblitum The FAQ mentions that ld: warning: path <some-path> following -L not a directory
warning is a cmake issue and can be safely ignored.
@Valloric I imagined that. My point was, it was the only output that changed between the configuration that didn't work and the one that did... It feels strange to get the same cmake output stating to use the same configuration, but not behaving identical afterwards.
Not sure what I'm doing wrong. It looks like YCM is linking against system Python on OS X 10.7, as is MacVim installed from homebrew. YCM compile messages:
Found PythonLibs: /Library/Frameworks/Python.framework/Versions/2.7/Python (found suitable version "2.7.1", minimum required is "2.5")
Found PythonInterp: /usr/bin/python (found version "2.7.1")
MacVim:
py import sys; print (sys.version, sys.executable):
('2.7.1 (r271:86832, Jun 16 2011, 16:59:05) \n[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]', '/usr/bin/python')
Any ideas?
YCM finds the python to link against from your PATH. Whatever you get from /usr/bin/env python
and /usr/bin/env python-config
is what it will compile against (and if those don't both point to the same installation you may have some problems).
The real bug here is in MacVim (and possibly Vim). I was working on a patch for MacVim (which could also be applied to the homebrew formula in the meantime) but got busy and haven't finished it up yet. Short version: in MacVim's build process is that, if it detects you are on OS X, it passes -framework python
during compilation but neglects to add a "framework path" to point to the found python. A side effect of -framework is that even though the configure script says it finds the python and python config dir you wanted it to, it then ignores all of that in favour of the framework, which it will only find at the default location.
There's a whole other messy problem if you happen to want to use a python in /Library/Frameworks
like the installer packages give you... but that's another story.
I'll try to push out what I have today and I'll reference it here for you guys.
Whoorah, this looks like it's fixed.
My workaround was to use python3 instead. Below is my argument list from "brew edit macvim" command.
args = %W[
--with-features=huge
--with-tlib=ncurses
--enable-multibyte
--with-macarchs=#{arch}
--enable-perlinterp
--enable-python3interp vi_cv_path_python3=/usr/local/bin/python3
--enable-pythoninterp
--enable-rubyinterp
--enable-tclinterp
--with-ruby-command=#{RUBY_PATH}
]
Recently, I ran into the same SIBAGRT
problem. Here was my setup:
- OS X 10.8
- System had Python 2.7.2, BUT I had installed 2.7.6 binary from http://python.org (installed using the 64-bit OS X installer), and made sure the 2.7.6. version could be found in
PATH
. - I had deployed MacVim (and Vim) by downloading from https://code.google.com/p/macvim/ and symlinking (
/usr/local/bin/vim -> /usr/local/bin/mvim
) andPATH
and putting MacVim in/Applications
.
I compiled YCM using install.sh
but ran into the SIGABRT
problem when starting Vim.
Reading the above comments, it was clear that the pre-compiled MacVim binary I had downloaded was utilizing the incorrect python library (Homebrew/legacy-homebrew#17908). Temporarily removing YCM from ~/.vim/bundle
and running :python import sys; print(sys.version)
in Vim confirmed this (it returned 2.7.2 instead of 2.7.6).
Python.org's 2.7.6 python was in /Library/Frameworks/Python.framework/Versions/
but the system's 2.7.2 python was in /System/Library/Frameworks/Python.framework/Versions/
. The main issue was that the pre-compiled MacVim binary was linked against the incorrect python lib:
$ otool -L /Applications/MacVim.app/Contents/MacOS/Vim | grep Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
To rectify the problem, I made the following symlinks in /System/Library/Frameworks/Python.framework/Versions
sudo mv 2.7 _2.7
sudo rm Current
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7 2.7
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7 Current
After that, I re-ran install.sh
and everything turned out fine.
This is more of a bandaid since I didn't recompile MacVim, but it worked.
I encountered this issue with MacPorts and the solution was quite simple.
You have to download python_select with:
sudo port install python_select
you can list all available versions of python in the system with:
port select --list python
then make your MacPorts python the active python with:
sudo port select --set python python27 (or whatever version of python you want to have as current)
finally, you can run ./install.sh normally and it will link with the correct Framework
I ran into the same SIG ABRT problem with a MacPorts Python, and was able to fix it using the instructions @harciga provided.
problem is recurring now.
I had the problem as well, after I reinstalled macvim, but the problem seems to be with brew/macvim, since it seems like it isn't linking properly against the brewed python. The fix in Homebrew/legacy-homebrew#17908 still works
Try brew uninstall macvim
and brew install macvim
to rebuild mvim based on Homebrew's python, it works.
One reason is we had brew install macvim
before we got Homebrew's python, that macvim was then built on Mac OS shipped python. rebuild would resolve this conflict.
@demoslam nope sorry, that doesnt fix it.
I have:
- Python 2.7.5 as the system version (OSX 10.9.1).
- Python 2.7.6 installed through MacPorts, selected as current with port select.
- MacVim 7.4.52 installed through MacPorts.
- Latest YCM compiled through install.sh.
Then:
- Everything works fine if I start MacVim from the terminal (using mvim script). I don't mean vim terminal version, but vim graphical version started from the terminal.
- I get the SIGABRT when starting MacVim app graphically (clickin on the MacVim app, or through QuickSilver).
- I get the SIGABRT too if, once started from the terminal (and working fine), I press Cmd-N to open a new window.
I've tried everything mentioned in this thread to no luck.
For whatever reason, MacVim started graphically seems to always pick python's system version.
??????
i had to brew uninstall macvim python && brew update && brew install python macvim
and it seems to work again
for homebrew users, the current macvim version (7.4) with Python (2.7.6) problem has been fixed,
Homebrew/legacy-homebrew#26496, please brew update, and reinstall macvim
I was able to get this working, but only by deciding to using either Homebrew MacVim + Homebrew Python (then recompile YCM) or downloaded MacVim + system Python (then recompile YCM). Both work fine on OS X 10.9, it just seems like you have to pick one "set" or the other.
Will YCM compile on OSX 10.7.5 with downloading libclang? I have llvm version 4.2 (clang-425.0.28) clang++ (same) llvm-g++ 4.2 (GCC) and llvm-gcc 4.2 (GCC)
I have the same problem, using the lastest version of Python 2.x, MacVim and HomeBrew... how to solve them? I can unlink the new version of python, because I have some app using that..
Having the same problem. I think something is currently screwed up in the homebrew formula - reverting to the previous formula for MacVim 7.4-72 works.
cd /usr/local/Library/Formula
git checkout db04c3a /usr/local/Library/Formula/macvim.rb
brew uninstall macvim
brew install macvim
...then compile & install YouCompleteMe
Hi wilsaj, these works for me, thanks!
The following steps fixed my setup.
Fix $PATH first.
sudo vim /etc/paths
Make sure /usr/local/bin is placed before /usr/bin
1 /usr/local/bin
2 /usr/bin
Delete the MacVim app, if you have installed a binary or if see below.
YCM fails when using the python version shipped with the mac. Like below.
$ otool -L /Applications/MacVim.app/Contents/MacOS/Vim | grep Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
Use homebrew to install python and macvim
brew install python macvim
I had the same crash with a MacPorts setup, but I've fixed it. When running install.sh it would say
-- Found PythonLibs: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python (found suitable version "2.7.9", minimum required is "2.6")
-- Found PythonInterp: /usr/bin/python2.6 (found suitable version "2.6.9", minimum required is "2.6")
A clear mismatch, even after running python select. The problem was that the system Python was 2.6, the MacPorts python was 2.7. In the script it searches for libraries from python 2.6 or 2.7, but for the interpretor it searches for python 2.6
So I edited third_party/ycmd/cpp/ycm/CMakeLists.txt to use 2.7 instead of 2.6 in the find_package lines
Just tried this today and though I'm getting this:
-- Found PythonLibs: /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found suitable version "2.7.9", minimum required is "2.6")
-- Found PythonLibs: /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found suitable version "2.7.9", minimum required is "2.7")
-- Found PythonInterp: /usr/local/bin/python2.7 (found suitable version "2.7.9", minimum required is "2.7")
When running mvim
I'm getting again:
Vim: Caught deadly signal ABRT
Vim: Finished.
😢 sadly still no 🎲
I'll link issue #1351 here for anyone that's compiling vim from sources in OS X using a custom python and finding problems. The Vim codebase is currently broken to pick and link a correct python while building on OS X.
@beaumartinez solution works for me. Thanks.
It's unfortunate that YCM suffers from such fragility. I've spent a day trying to figure out how to get the YCM install.sh to use ONLY the /usr/local/ version of Python2.7 instead of the Redhat 6 default of /usr/bin/python2.6.
Getting the the compile and link stages to use python 2.7, is not that hard. Getting the build/cmake/runtime to use the python2.7 interpreter rather then python2.6 is proving damned near impossible without lobotomizing the base system (not allowed!).
@suykerbuyk The docs mention solutions to the problems you face.
For the install step, one can (for example) pass -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
to the cmake call.
For using the correct python interpreter for ycmd at runtime, there's the g:ycm_path_to_python_interpreter
Vim option you can set.
Finally, YCM (and ycmd) should also work just fine with Python 2.6. Build/test bots ensure that remains the case.
I have the downloaded MacVim with MacPorts and the following worked for me:
$ env PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin/ bash install.sh --clang-completer
@Valloric - Thanks for chiming in with those really helpful tips. I confess to having been quite frustrated when I wrote that. The fact is, your YCM is so damned good when everything works, that it makes life without it miserable. You named it ever so appropriately, and more than anything else, I am very grateful for this wonderful tool you've created.
Unfortunately, it is a rare event when I can work on the same machine or even distro for more then a few weeks at a time. I don't know much about Python, and I certainly don't know much of anything on how a Python environment bootstraps and initializes, but with each YCM install, I'm learning a bit more... ;)
So far I've found my favorite platform of FreeBSD to be the most deterministic in setting up YCM.
Eventually, I'd like to get down to a single set of tar balls and some scripts that will let me drop a blob on any (mostly) Posix system, and rebuild my tools from source and be ready to roll without the constant cycle of building Python with a tweak, building Vim with a tweak, installing/building YCM with sequential list of tweaks until it all just "works". Perhaps something not unlike the submodules within YCM itself work (or .PBI's in PC BSD).
I've fixed my issue that was thwarting me yesterday, but 90% of my problems came down to a module initialization in third_party/requests/requests/utils.py. Specifically: "from . import certs" would fail to find/load "certs".
I looked into the sections on how the python search path was being modified upon initialization, but I never did figure out what was really broken. I just know that when I had CMake's find python modules aligned to the real, intended runtime versions of Python, it all just started to work.
In a couple of weeks when I'm on another platform, I will definitely add your RTFM notes to the list of things I start with.
I have this problem for quite some time. The solution was not about updating brew, uninstalling macvim, python or whatever. I did that several times and didn't work.
Thanks to @rfurman for helping me solve this one.
So the solution is to make sure Found PythonLibs
and Found PythonInterp
are using the same paths your vim was built with. In my case I built with homebrew, so I want to be sure it has /usr/local
in there and the version matches. I was getting the system's python 2.7.5 but homebrew installed python 2.7.9 and built macvim with it, so I changed the makefile YCM uses to match this.
cd YouCompleteMe
sed -i '' -E 's/(Python[a-zA-Z]+) 2.6 REQUIRED/\1 2.7 REQUIRED/' third_party/ycmd/cpp/ycm/CMakeLists.txt
./install.sh --clang-completer
No crashes!
By the way, I tried to install inside vim using vim-plug doing the above replacement and install automatically, but it didn't work. For some reason it picked a different PythonInterp.
This is no perfect solution. I believe the makefile shouldn't get "any python library that matches" but rather the python library that was linked to macvim. I think that would be the correct fix.
@imkira - your observations, fix, and suggestions are completely in line with what my experience has been. There are too many moving pieces involved in second guessing which Python components to use during cmake, make, YCM runtime, and VIM itself and it all makes for an unfortunately very fragile ecosystem.
Next time I have to deploy onto a system that I don't/can't have root access to, I'm going to try one more time to build the entire self contained stack in either $HOME/local or what will become $VIMHOME/local from dash compatible script.
@imkira thank you SOOOOOO much 🙇
I had a lot of issues with Homebrew
due to a broken Xcode
Plugin; but after figuring out it was that; installing python and MacVim via homebrew and then running the command you posted everything worked as smoothly as it should have been from the beginning 😄
Can't thank you enough 👍
This problem annoys me for days and I finally came to a solution as below:
brew rm python
; // remove brew installed python completely, but if you really have to use that, act with caution.brew rm macvim
; // remove installed macvim first to prepare for new installation.brew install macvim --with-python
; // new installation of macvim with the support of python- Either repeat your installation with YouCompleteMe, or if you have already installed and compiled it, you can just enjoy it(this is exactly my case).
Hope somebody find this useful.
@noscripter your general solution worked for me, i also had to do a brew rm vim; brew install vim --with-python
, and then recompile YouCompleteMe linking to the new python installed in steps 1 and 2. Thanks!
For homebrew it should actually be something like
env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin/ bash install.sh
which uses default homebrew linked thing.
@imkira's suggestion (to edit YouCompleteMe/third_party/ycmd/cpp/ycm/CMakeLists.txt
to insist on Python >=2.7) was half of my fix. Specifically, after this fix, the YouCompleteMe build happily reported, near the top, that it was finally using brew's Python:
-- Found PythonLibs: /usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7")
-- Found PythonInterp: /usr/local/bin/python2.7 (found suitable version "2.7.10", minimum required is "2.7")
Note that /usr/local/bin/python2.7 is symlinked to brew's python in /usr/local/Cellar… Before this CmakeLists.txt edit, install.sh
was reporting different PythonLibs and PythonInterp:
-- Found PythonLibs: /usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.6")
-- Found PythonInterp: /usr/bin/python2.6 (found suitable version "2.6.8", minimum required is "2.6")
Once these two matched, I thought I was home free. But MacVim was still crashing with ABRT!
The other half involved forcing MacVim, which I was building from source per the YCM docs, to use brew's Python. Turns out it was built using system python: remove YouCompleteMe/ from ~/.vim/bundle
to avoid ABRT crash and invoking :python print(sys.version)
reported using an older python, which told me it was non-brew. In MacVim, ./configure --enable-pythoninterp
was still reporting
checking Python's install prefix... (cached) /System/Library/Frameworks/Python.framework/Versions/2.7
checking Python's execution prefix... (cached) /System/Library/Frameworks/Python.framework/Versions/2.7
(cached) checking Python's configuration directory... (cached) /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
The "(cached)" seemed a problem so I deleted MacVim/src/auto/config.cache
and upon re-running ./configure --enable-pythoninterp
, configure found brew's python.
(If MacVim's configure was still finding system python, I'd have tried the solutions on SO to get MacVim to find the right Python. But it looks like brew remove python && brew update && brew install python
, plus deleting MacVim's configure cache, was sufficient.)
Moved YouCompleteMe back into ~/.vim/bundle
and all is well 😂!
(This was all on Mavericks. Interestingly, I also installed MacVim from github and YCM on a fresh clean Yosemite this morning and didn't run into any
of this… lucky.)
Following @imkira's suggestion as well as @fasiha's I almost got everything working, but in the end the only thing that solved it for me was finally taking @Valloric's advice in the README and installing MacVim directly, rather than using homebrew or trying to work with another version of vim. If you're having this problem and did not build MacVim yourself, I highly recommend you try this first.
This worked for me. Hope it helps someone else.
NOTE:
/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/Current
the 2.7.10 portion needs to be the latest version you have installed with Homebrew
brew rm -f python
brew rm -f macvim
brew install python
brew linkapps python
brew install macvim --with-python --with-override-system-vim
brew linkapps macvim
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
Update: 8/4/2015
I just used this again after upgrading python on my mac and it worked. 😄
@harciga solution works for me
however, I have to select python27-apple for it to run
@jmeridth Also works for me...
Another way to get things working, taking a page from the OS X install in YCM's readme:
brew cask uninstall --force macvim
brew uninstall -f vim
brew unlink python
brew cask install macvim
cd /usr/local/bin/
ln -s mvim vim
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
Now everything should work as expected and you didn't have to mess with system Python.
I resolved by removing redundant python. For me seems it's because if my OSX has different version of python installed, from System, from homebrew, from Xcode etc.
So use:
type -a python
to see where are those python installed and remove them. Seems I can't remove the one come with the system:
/usr/bin/python
so I kept that one and remove all others like:
cd /Library/Frameworks/
mv Python.framework x
Then go to Ycm and run:
./install.sh
to recompile and install ycm.
Then it works for me.
@ActionScripted nice, that worked for me.
For the record:
I have found that if using pyenv to install python and you get the infamous
Fatal Python error: PyThreadState_Get: no current thread
Then you must add the --enable-shared
flag manually:
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.10
Correction. That works for python 3.5, but it looks like pyenv can't build --enable-shared on some versions (like 3.3.6). Better to try:
PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 2.7.10
I face the same error. cause I have three python 2.7 install. one system. one download from the python.org, one install from brew. I fixed it with the following. hope may help others.
# rm python.org python
# have a look at this: http://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4
# reinstall python and macvim
brew rm python
brew install python
brew rm macvim
brew install macvim
# rebuild YCM
cd .vim/bundle/YouCompleteme
./install.py
now it works.
Recently I install a python 2.7.12 apart from the system one 2.7.10 and face the same error. But maybe because I did not install the macvim by homebrew before, below works for me.
-- No uninstalling python and macvim.
-- Just install macvim
brew install macvim
-- rebuild YCM
cd .vim/bundle/YouCompleteme
./install.py
I think it may be not necessary to reinstall the homebrew's python because this error is only related to the python configuration in MacVim and YouCompleteMe. And if you have a homebrew's python, when it is about to build the MacVim, it should know to configure it with the homebrew's one. The same as the YouCompleteMe.
Anyway, thanks all and especially to @hackrole .
Just figure it out, it's mainly because the _io.so file is different in python 2.6 / 2.7.5 / 2.7.13, so if you still want to use the homebrew version python in terminal using "python", you should copy the old version io.so file into the 2.7.13 directory.
First, run the following code in terminal
sudo find / -name _io.so
Here is mine:
/Applications/Google Drive.app/Contents/Resources/lib/python2.7/lib-dynload/_io.so
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
/Users/Nico/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Second, copy the 2.7.13 version io file to backup
cd Desktop
mkdir backup_python
cp /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so backup_python/2.7.13_io.so
Third, copy the old version to replace the new one
cp /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Then it will be all set!
Thanks samueljon, changing to python 3 by add python flag:
--enable-python3interp vi_cv_path_python3=/usr/local/bin/python3
--enable-pythoninterp
by editing "brew edit macvim" works for me
uninstalling brew installed python2.X worked for me.