Ruby 1.9和Vim 7.3发布的时间已经过了很久,但Mac下的Macvim始终不能支持Ruby 1.9。使得Ruby的编程,另一些插件(Commant-t)不能使用。尝试编译源码,发现几次都在RUBY_CFLAGS上报错。最后修改config.mk成功编译。
首先,下载Macvim源码包,https://github.com/b4winckler/macvim
需要长期更新,则使用git clone git://github.com/b4winckler/macvim,有新的更新时执行git pull更新作者最新的更新。
First, please download the source code of the MacVim. https://github.com/b4winckler/macvim, you could use “git clone” to clone a copy, and use “git pull” to update the newest code.
接下去,进入源码包中src目录,输入命令,这里还包含python。
Then, you could go to the src directory, and input the command that contain python compile para.
./configure --with-features=huge --enable-pythoninterp \
--enable-rubyinterp
这里需确认Ruby 1.9的安装方式,我这是下载源码包,编译安装在/usr目录下,即覆盖了系统默认的Ruby 1.8.6。
如果使用homebrew或rvm安装,和之后的方法是相似的,编译失败一般是RUBY_CFLAGS和RUBY_LIBS的指定路径错误造成的。需要指出的是使用rvm的ruby 1.9是不支持Command-t的,这点作者在help文件里有指出。
There should be confirm the installed pattern of Ruby 1.9. I recommend download source code, and point the prefix to /usr, which cover the default Ruby.
If you use homebrew or rvm to install, the method is the same as above. But if compile fail, RUBY_CFLAGS and RUBY_LIBS are the important checkpoint. Need to point, command-t isn’t support the ruby 1.9 of using rvm installed pattern.
编译之前,打开src/auto生成的config.mk文件,修改对应代码行
Before the compile, open the file “config.mk” in directory src/auto, and modify the code line.
RUBY = /usr/bin/ruby
RUBY_SRC = if_ruby.c
RUBY_OBJ = objects/if_ruby.o
RUBY_PRO = if_ruby.pro
RUBY_CFLAGS = -I/usr/include/ruby-1.9.1 -I/usr/include/ruby-1.9.1/x86_64-darwin10.7.1 -DRUBY_VERSION=19
RUBY_LIBS = -lruby-static -lpthread -ldl -lobjc -L/usr/lib
看到这再执行make & sudo make install 即可成功让vim支持ruby 1.9。
可以用这以下命令检查链接情况,是否已经关联到ruby。
Last, execute the “make & make install”. Ah, vim is support ruby 1.9 now. And you can check the link using the command below.
otool -L ~/Download/MacVim/macVim.git/src/MacVim/build/Release/MacVim.app/Contents/MacOS/Vim
Vim:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 152.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.42.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.53.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1038.35.0)
关联Vim到/Applications/MacVim.app/Contents/MacOS/Vim上,这样在Shell中的Vim也成功升级到了7.3+ruby…
Shell的Vim支持通过 vim –version查看,有+号的即支持,如需要用相似方法增加支持,如python 3, perl等
You can watch the support condition via “vim –version”. The “+” mean supported.
Happy~~