Wednesday, November 2, 2011

Segmentation Fault Running Vim on OS X 10.7.2 Lion

So after upgrading to OS X 10.7.2, vim has been terminating with a segmentation fault whenever I run an external shell command from inside vim.

Aside from normal shell commands, I frequently run fmt from inside vim to format my text to 78 / 80 characters wide.

To solve this, simply compile vim from source:
  1. Download the latest source, e.g. ver 7.3:
    curl ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2 -O
  2. Untar:
    tar -xvjf vim-7.3.tar.bz2
  3. Configure to build without GUI:
    ./configure --enable-gui=no
  4. make
  5. make install
  6. Edit your .bash_profile to make sure running vim will run the recently build vim at /usr/local/bin/vim instead of the default at /usr/bin/vim:
    PATH=/usr/local/bin/:$PATH; export PATH
  7. All Done!

3 comments:

  1. Thanks, I thought it was a plugin problem, uninstalled all of them and was still getting the error.

    I ran into some problems with unicode and found the solution here: http://blog.wwwjfy.net/2011/03/02/compile-vim-7-3-in-mac-os-x-10-6-6/

    ReplyDelete
  2. Thanks for this, I thought it was something wrong with my system. I'm now installing vim with brew:

    brew install vim --override-system-vi --without-ruby

    The flags make it match the language support I have on my Linux machines (I share my homedir - and therefore my ~/.vim and ~/.vimrc - with git).

    ReplyDelete