Here’s how to reinstall vim on Mac OS X Lion using Homebrew.
The Vim installed by default on Mac doesn’t have Ruby options enabled, so we’ll reinstall Vim to enable this.
■ Installing Vim with Homebrew
The official Homebrew follows a development policy of not including formulas for programs that are installed by default on MacSo, from the GitHub page below, right-click on 'raw' in the upper right of the code text area and copy the URL,・Source: Homebrew の Vim formula 書いた - Yarukidenized:ヤルキデナイズド (I wrote a Vim formula for Homebrew - Yarukidenized)
・github: Vim formula for Homebrew — Gist
Then install as follows:
$ brew install https://raw.github.com/gist/721952/e99293dc36c9b5c27aec0a4024b848ce50b9b126/vim.rb --enable-interp=ruby --force
==> ./configure --disable-gui --without-x --disable-gpm --disable-nls --with-tlib=ncur
==> make install
/usr/local/Cellar/vim/7.3.294: 1233 files, 21M, built in 12.9 minutes
In Homebrew, OS X built-in commands won’t install without the —force option, so we add that option.
Also, the options available during installation are as follows:
["--with-features=TYPE", "tiny, small, normal, big or huge (default: normal)"],
["--enable-interp=NAME,...", "lua, mzscheme, perl, python, python3, tcl and/or ruby"]
■ ~/.bash_profile
# Prioritize /usr/local/bin over /usr/bin
export PATH=/usr/local/bin:$PATH
Reload the .bash_profile:
$ source ~/.bash_profile
Confirm that the vim path has changed from /usr/bin/vim:
$ which vim
/usr/local/bin/vim
When I tried to use Vim, an error occurred…
$ vim
dyld: Symbol not found: _environ
Referenced from: /Users/your_username/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.1.9.1.dylib
Expected in: flat namespace
in /Users/your_username/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.1.9.1.dylib
Trace/BPT trap: 5
The cause was that it was compiled using Ruby 1.9.2.
・Reference: osx - Trying to compile vim on OS X? - Stack Overflow
To reinstall vim, let’s uninstall vim first:
$ brew uninstall vim
Uninstalling /usr/local/Cellar/vim/7.3.294...
Use Ruby 1.8.7 so it can compile properly:
$ rvm use 1.8.7
Install vim again:
$ brew install https://raw.github.com/gist/721952/e99293dc36c9b5c27aec0a4024b848ce50b9b126/vim.rb --enable-interp=ruby --force
==> ./configure --disable-gui --without-x --disable-gpm --disable-nls --with-tlib=ncur
==> make install
/usr/local/Cellar/vim/7.3.294: 1233 files, 21M, built in 12.9 minutes
Confirm that vim is properly installed with +ruby:
$ which vim
/usr/local/bin/vim
$ vim --version | grep ruby+reltime -rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime
Linking: /usr/bin/llvm-gcc -L. -L/usr/local/lib -o vim -lm -lncurses -liconv -framework Cocoa -lruby -lobjc -L/Users/your_username/.rvm/rubies/ruby-1.8.7-p357/lib
That’s all from the Gemba about reinstalling vim on Mac OS X Lion with Homebrew.