Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I tried to upgrade from the default vim install on Mac OS X (vim 7.2) to the one used by MacVim (vim 7.3) by creating a symlink:

ln -s /Applications/MacVim.app/Contents/MacOS/Vim /usr/bin/vim 

However, now I get the following error messages:

sk@supernova:~/ > /usr/bin/vim
E254: Cannot allocate color Red
E254: Cannot allocate color White
E254: Cannot allocate color Blue
E254: Cannot allocate color Red
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Brown
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color Yellow
E254: Cannot allocate color Red
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color DarkCyan
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color Red
E254: Cannot allocate color Yellow
E254: Cannot allocate color Black
E254: Cannot allocate color LightGrey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color LightGrey
E254: Cannot allocate color LightBlue
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Blue
E254: Cannot allocate color LightCyan
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Grey90
E254: Cannot allocate color Grey90
E254: Cannot allocate color LightRed
E254: Cannot allocate color DarkGrey
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Cyan
Error detected while processing /Users/sk/.vimrc:
line    1:
E185: Cannot find color scheme desert
Press ENTER or type command to continue

Anyone knows how to fix this? If I run just vim or /Applications/MacVim.app/Contents/MacOS/Vim directly I don't get the error messages. Only if /usr/local/bin/vim gets called. Either directly or via another command line application.


Just if someone comments that I could have simply created an alias, I actually did that before

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

however, some other command line tools were still using /usr/bin/vim.

share|improve this question
add comment

4 Answers

up vote 7 down vote accepted

This is a known issue. From :help MacVim:

Note: Starting MacVim by creating a symlink to >
    .../MacVim.app/Contents/MacOS/Vim with 'ln -s' does not work.

I found a lot of people getting a string of E254 errors from using a symlink. See this ticket on the MacVim issue repository. The solution follows:

    Most likely this is because you have symlinked directly to
    the Vim binary, which Cocoa does not allow.  Please use an
    alias or the mvim shell script instead.

MacVim comes with a startup shell script, mvim. You can alias it to vim if you'd prefer to use it instead of the system vim. If you want to start vim in the terminal rather than as a gui application, set the alias to mvim -v. Add export EDITOR=vim to your ~/.bash_profile to make sure that any terminal applications are using the now-aliased vim. This should cover all your bases.

share|improve this answer
add comment

Looks like it has something to do with your color scheme. Deactivate the desert theme in your .vimrc and see whether it helps. Change colorscheme desert to 'colorscheme desert.

The best way to avoid such problems is to install vim 7.3 from the mac ports.

share|improve this answer
    
Unfortunately not. I tried that before. I then don't get the E185: Cannot find color scheme desert error, but still all the others. –  znq May 17 '11 at 13:08
add comment

Changing something in /usr/bin is not the best way to go about things as Apple can just overwrite it again.

The errors are probably as @karmatic says but probably the best thing to do here is put the symbolic link in /usr/local/bin and make your shell have that in the path earlier than /usr/bin.

As far as I know no command line tool uses /usr/bin/vi directly (I use emacs so I would spot having to use vi) What they do is use the environment variable $EDITOR so set that to /usr/local/bin

share|improve this answer
add comment

I don't have any rep yet so I can't comment on michaelmichael's answer but based on his answer I edited the mvim wrapper script to add another case statement. So that if $name was vim it will add the -v option. I then symlinked /usr/local/bin/mvim to /usr/local/bin/vim.

47 # vimdiff, view, and ex mode
48 case "$name" in
49     vim)
50         opts="$opts -v"
51         ;;
52     *vimdiff)

This was all because in some cases I couldn't rely on EDITOR being set or on aliases but I could rely on /usr/local/bin being in PATH.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.