Vim cannot find syntax.vim

28,384

Solution 1

Can you just make a symlink to where vim thinks it should be? i.e.

sudo ln -s /usr/local/share/vim/vim74/syntax/syntax.vim /usr/share/vim/vim74/syntax/syntax.vim

(If this target directory doesn't exist, then link the higher-level directory instead.)

Solution 2

In bash run:

export VIMRUNTIME=/usr/share/vim/vim73

Then in vim run:

:syntax on

(In my case vim was looking in /usr/share/vim/vim74, whereas there was no /usr/local/share/.... I was on an AWS EC2 Ubuntu.)

Also, it needed to be VIMRUNTIME, not VIMRUNTIMEDIR.

Note that for permanence you can place the above export line into your shell's personal initialization file, e.g. ~/.bash_profile.

Solution 3

The problem is the make command.

make VIMRUNTIMEDIR=/usr/share/vim/vim74

From the question, syntax.vim is actually located in /usr/local/share/vim/vim74 so you should instead be using the following.

make VIMRUNTIMEDIR=/usr/local/share/vim/vim74

In general, the VIMRUNTIMEDIR variable used by make should be consistent with the prefix variable used by the configure script.

Share:
28,384

Related videos on Youtube

Dillmo
Author by

Dillmo

Updated on September 18, 2022

Comments

  • Dillmo
    Dillmo over 1 year

    Recently, I needed to build Vim from source to use a plugin that required Lua interpreting. This worked fine on my laptop, but my tower computer is having some issues. Any time I run Vim, I recieve the message:

    Error detected while processing /home/XXXXXX/.vim/vimrc:
    line   55:
    E484: Can't open file /usr/share/vim/vim74/syntax/syntax.vim
    

    Not surprisingly, Vim then fails to highlight syntax, and throws a bunch of other errors when editing text.

    Having done some research myself, I can tell that syntax.vim is actually in /usr/local/share/vim/vim74/syntax/syntax.vim, as opposed to the previously mentioned directory. How can I solve this?

    More Info

    Vim was installed using checkinstall. To compile it, I ran the commands:

    ./configure --with-features=huge --enable-cscope --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu --enable-multibyte --enable-fontset --disable-gui --disable-netbeans --enable-luainterp=yes --with-lua-prefix=/usr/include/lua5.1 --enable-largefile
    make VIMRUNTIMEDIR=/usr/share/vim/vim74
    
    • Sparhawk
      Sparhawk about 10 years
      Can you just make a symlink to where vim thinks it should be? i.e. sudo ln -s /usr/local/share/vim/vim74/syntax/syntax.vim /usr/share/vim/vim74/syntax/syntax.vim
    • Dillmo
      Dillmo about 10 years
      This seems to have worked: sudo ln -s /usr/local/share/vim/vim74 /usr/share/vim/vim74. I'm leaving the question open for now, in case I run into other related issues.
    • Sparhawk
      Sparhawk about 10 years
      You probably would want to ask a new question if you have a separate issue. (If this solution works at all, I can't imagine how it could partially fail elsewhere.) Anyway, I wrote it up as an answer…
  • Dillmo
    Dillmo about 10 years
    Your answer definitely helped: +1 for that. However, since it was not quite correct, I can't mark it as a solution. The command sudo ln -s /usr/local/share/vim/vim74 /usr/share/vim/vim74 worked instead. Thanks for your help anyways.
  • Sparhawk
    Sparhawk about 10 years
    Okay, but I did write "If this target directory doesn't exist, then link the higher-level directory instead." Anyway, up to you. You can always edit in the exact command if you like. Or create your own answer. Up to you, either way, but probably best to accept one or the other.
  • shay.porteous
    shay.porteous over 9 years
    Instead of symlinking the result, adding --prefix=/usr to the configure call might have installed to the correct location right away.
  • bjd2385
    bjd2385 almost 6 years
    This works for me. I didn't make the connection while building vim from source for YouCompleteMe.
  • trysis
    trysis over 5 years
    I found I didn't need VIMRUNTIME or the make prefix. If I provided either, or both, I got problems. With only the make prefix I got the OP's problem, with both I got an error with the SlateBlue color. I don't believe I tried with just VIMRUNTIME.
  • Osama Gamal
    Osama Gamal over 4 years
    That works! It is an easy fix for people with no root access.
  • Sridhar Sarnobat
    Sridhar Sarnobat over 2 years
    Yes. I was unpacking rpm files manually on a server without root access so this is the only option.