Cygwin: how does /usr/bin/vim resolve to a specific version of vim?

0

This started when I ran vim in Cygwin and all of a sudden I got the error message: E185: Cannot find color scheme 'alduin' when I didn't used to get this error prior to today.

I had been messing with installing Cygwin packages, and must've inadvertently installed a new version of vim(?): I now have the folders /usr/share/vim/vim74/ and /usr/share/vim/vim80/.

When I run vim the splash screen does say it's version 8.0.1567. And I guess I put alduin.vim in .../vim74/ and not .../vim80/

My question: how does /usr/bin/vim.exe get associated with a particular version of vim? I.e. when I run "vim" why is vim 8.0 invoked and not vim 7.4?

> which vim
/usr/bin/vim
> 
> ls -l /usr/bin/vim*
-rwxr-xr-x 1 User None 2645011 Mar  4  2018 /usr/bin/vim.exe
lrwxrwxrwx 1 User None       7 Dec 14 21:39 /usr/bin/vimdiff -> vim.exe
-rwxr-xr-x 1 User None    2099 Mar  4  2018 /usr/bin/vimtutor
lrwxrwxrwx 1 Usr None       8 Dec 14 21:31 /usr/bin/vimx -> gvim.exe
> 
> find /usr/share/vim/vim74/ -name "*.exe"
> find /usr/share/vim/vim80/ -name "*.exe"
> 
> printenv | grep -i vim
> 

Note, above, that /usr/bin/vim is not a softlink to the executable in one of my two vim versions' directories, which is how I'd have assumed this version-selection would've been done.

StoneThrow

Posted 2018-12-20T07:12:19.213

Reputation: 295

Why are you looking for the .exe in /usr/share? That's not where the symlink points (and not where executables are kept in general). – user1686 – 2018-12-20T07:32:39.993

@grawity - Umm...not really knowing what I was doing, I think I did a "find / -name "*vim*" and those locations came up in the results. But here's the crux of my question/confusion is: when I run "vim", I think I am running /usr/bin/vim - true? I think this is backed up by the output of "which vim" But then why isn't /usr/bin/vim a symlink? – StoneThrow – 2018-12-20T07:44:57.093

Answers

2

Through the package manager (Cygwin's, but the same applies to "real" Linux distributions as well), you can only install one particular version of Vim. So /usr/bin/vim.exe (with /usr/bin being owned by the package manager) does not need to be a link. The Vim package can directly place the executable there.

Now for the runtime files (under /usr/share/vim), following that "single version" argument, there's also no need for a version number inside the path, but there's a version in Vim's default install script (Makefile), and most package maintainers keep it that way. Depending on how your (accidental) upgrade worked, you either have a full abandoned Vim 7.4 runtime at /usr/share/vim/vim74/ (and vim.exe got overwritten), or this is just a mostly empty skeleton directory hierarchy that only contains those files that you added to it (like your colors/alduin.vim).

To avoid such problems in the future, please stay off the system directories, and instead place your Vim customization in the user-specific directory; i.e. ~/.vim/, as described by :help load-plugins. Unix / Linux (where Vim comes from) has a clean separation between system and user, and even though this has been less pronounced under Windows (at least in its early history), it's advisable to stick to this, especially with Cygwin.

Ingo Karkat

Posted 2018-12-20T07:12:19.213

Reputation: 19 513