Compiled vim from source on Mac OSX and getting 'shell returned 127' error?

12,767

Solution 1

I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).

You should be able to throw this in your .bashrc:

alias vim=/Applications/MacVim.app/Contents/MacOS/vim

Solution 2

:!q is not :q!. This is probably not a bug.

The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)

There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.

The upshot here is basically check to make sure you typed in your commands right, I guess.

Solution 3

This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.

system "./configure", "--prefix=#{prefix}",
                      "--mandir=#{man}",
                      "--enable-gui=no",
                      "--without-x",
                      "--disable-nls",
                      "--enable-multibyte",
                      "--with-tlib=ncurses",
                      "--enable-pythoninterp",
                      "--enable-rubyinterp",
                      "--with-features=huge"
system "make"
system "make install"
Share:
12,767
littlejim84
Author by

littlejim84

Updated on June 04, 2022

Comments

  • littlejim84
    littlejim84 almost 2 years

    On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?

    I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:

    /bin/bash: q: command not found
    
    shell returned 127
    
    Press ENTER or type command to continue
    

    ...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.

    Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.

    Any help would be fantastic!

  • muhmuhten
    muhmuhten over 13 years
    what's with all the systems? why not just use a shell script?
  • abdollar
    abdollar over 13 years
    homebrew is a package manager for osx. The system calls above are part of the formula which is a ruby script. See mxcl.github.com/homebrew
  • Lindsey Blackstock
    Lindsey Blackstock over 13 years
    I can't actually find the normal vim formula in the homebrew repository. All I find is macvim. Has it been removed?
  • abdollar
    abdollar over 13 years
    looks like its gone. Do the alias thing I guess /Applications/MacVim.app/Contents/MacOS/Vim
  • Mathias Bynens
    Mathias Bynens about 13 years
    alias vim=/Applications/MacVim.app/Contents/MacOS/vim