[Mac][Lion] Homebrew で Vim をインストールする方法
- 2012 3/4
Mac OS X Lion に Homebrew で vim を再インストールしたのでメモ。
Mac にデフォルトでインストールされている Vim は Ruby オプションが有効になってないので、これを有効にするために Vim をインストールし直します。
■ Homebrew で Vim をインストール
本家 Homebrew は Mac に標準でインストールされているプログラムの formula は収録しないという開発方針を取っている
とのことですので、下記の Github ページからコードのテキストエリア右上の ‘raw’ を右クリックして URL をコピーして、
・github:Vim formula for Homebrew — Gist
以下のように、インストールします。
$ 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 |
Homebrew では、OS X 付属コマンドはインストールさせてくれないので、–forceオプションを付けてインストールしています。
また、インストール時に付けれるオプションは以下の通りです。
["--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
# /usr/bin より /usr/local/bin を優先する export PATH=/usr/local/bin:$PATH |
.bash_profile を再読み込みします。
$ source ~/.bash_profile |
vim への Path が /usr/bin/vim から変わっていることを確認します。
$ which vim /usr/local/bin/vim |
いざ、Vim を使おうとするとエラーが発生しました。。。
$ vim dyld: Symbol not found: _environ Referenced from: /Users/bakorer/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.1.9.1.dylib Expected in: flat namespace in /Users/bakorer/.rvm/rubies/ruby-1.9.2-p290/lib/libruby.1.9.1.dylib Trace/BPT trap: 5 |
原因は、Ruby 1.9.2 を使ってコンパイルしていたせいみたいでした。
・参考:osx – Trying to compile vim on OS X? – Stack Overflow
vim を入れ直すために、vim をアンインストールします。
$ brew uninstall vim Uninstalling /usr/local/Cellar/vim/7.3.294... |
Ruby 1.8.7 を使って、コンパイルできるようにします。
$ rvm use 1.8.7 |
もう一度、vim をインストールします。
$ 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 |
vim が +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/bakorer/.rvm/rubies/ruby-1.8.7-p357/lib |
以上です。
【参考】