码迷,mamicode.com
首页 > 系统相关 > 详细

Mac Yosemite上安装macvim和YouCompleteMe

时间:2015-02-02 00:37:47      阅读:1002      评论:0      收藏:0      [点我收藏+]

标签:

今天在macvim上安装YouCompleteMe的时候,碰到一个运行vim崩溃的错误.查了半天终于解决!

先上一下安装macvim的过程

# install xcode and command line tools
$ xcode-select --install
# install homebrew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install python
$ brew install python
# install macvim
$ brew install macvim

然后编辑.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required
 
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin(‘~/some/path/here‘)
 
" let Vundle manage Vundle, required
Plugin gmarik/Vundle.vim
 
Plugin altercation/vim-colors-solarized
Plugin Lokaltog/powerline, {rtp: powerline/bindings/vim/}
Plugin kien/ctrlp.vim
Plugin scrooloose/syntastic
Plugin Valloric/YouCompleteMe
 
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

在vim中运行命令

:BundleInstall

完成后进入目录中

cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer

编译完成后,运行vim结果出错.

$ vim
Vim: Caught deadly signal ABRT
Vim: Finished.
Abort trap: 6

查了一圈发现,加一个参数后能正常工作

$ DYLD_FORCE_FLAT_NAMESPACE=1 vim

但毕竟这不是一个办法,最后在github上的issue页面上看到问题的解决办法:

brew unlink python

运行后依然无效!!!!崩溃!!!

然后继续看下去

$ otool -L /usr/local/Cellar/macvim/7.4-73_1/MacVim.app/Contents/MacOS/Vim | grep -i python
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)

而我的系统上默认的python是2.7.9,而且路径为/Library/Frameworks/Python.framework/Versions/2.7/python!

OK找到问题所在了,现在的任务就是需要把这两个Python的版本调整成为一致!!!!

HOW to do it? Google之找到办法,把所有的操作整理到一起给大家:

sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7
sudo mv /Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current
sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config /usr/bin/python-config

需要详细解释的童鞋,可以查看这篇文档.

执行这段shell之后,需要编辑~/.bash_profile将系统默认的Python路径指向/System/Library这个文件夹

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

改变Python版本后,执行vim就不再出现段错误了.

 

参考文献:

1. github issue#8

2. installing-homebrew-macvim-with-youcompleteme-on-yosemite 

3. Installing / Updating Python on OS X

 

Mac Yosemite上安装macvim和YouCompleteMe

标签:

原文地址:http://www.cnblogs.com/clivelee/p/4266559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!