Vim version changes without opening a new terminal, without restarting the computer. Simply, the next day my computer takes the repo version, which has been removed by apt before.

I've compiled vim from the source, because I needed some options, which is not compiled in the repo version. I've done it a few times before, but now on XUbuntu 18.04LTS the system forgets the compiled vim and somehow it pulls back the repo version, what I removed, at least I thought that. After being unsure whether I do the compilation and the post-compile setup correctly, I was following this link. I've also used checkinstall and last time I pulled vim8.2 back with dpkg -i deb_name, where deb_name is the name of the deb file checkinstall created.

I noticed, that when the compiled vim version is not recognized, the location where it was installed is also not available:

~ $ sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
update-alternatives: error: alternative path /usr/local/bin/vim doesn't exist
~ $ ls -l /usr/local/bin/ | grep vi
lrwxrwxrwx 1 root root      3 Mär 13  2018 ex -> vim
-rwxr-xr-x 1 root root    216 Feb 15  2019 pyvisa-info
-rwxr-xr-x 1 root root    218 Feb 15  2019 pyvisa-shell
lrwxrwxrwx 1 root root      3 Mär 13  2018 rview -> vim
lrwxrwxrwx 1 root root      3 Mär 13  2018 rvim -> vim
lrwxrwxrwx 1 root root      3 Mär 13  2018 view -> vim
lrwxrwxrwx 1 root root      3 Mär 13  2018 vimdiff -> vim

This is really strange, since I needed to execute this command to tell my system, where vim was compiled.

The location is on a local drive, the whole /usr is one logical volume, so it can not be disconnected.

I have removed vim with sudo apt remove vim vim-runtime gvim vim-common ebefore compiling. dpkg -l | grep vim has confirmed that I have no vim package installed. Also the shell tells me, that Command 'vim' not found. Although some time later - next day - vim is there again from the repo:

~ $ dpkg -l vim
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
ii  vim                                  2:8.0.1453-1ubuntu1.4   amd64                   Vi IMproved - enhanced vi editor

Installing the deb created by checkinstall solves the issue for about a day:

~/git_repos/vim $ sudo dpkg -i vim_20201104-1_amd64.deb 
[sudo] password for tibenszky: 
dpkg: warning: downgrading vim from 2:8.0.1453-1ubuntu1.4 to 20201104-1
(Reading database ... 487461 files and directories currently installed.)
Preparing to unpack vim_20201104-1_amd64.deb ...
Unpacking vim (20201104-1) over (2:8.0.1453-1ubuntu1.4) ...
Setting up vim (20201104-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

I have no clue what could have cause this issue, or how could I debug and solve this. Any help is appreciated.

Update: It seems like that apt's daily upgrade overwrite my vim version. So the question is changed to 'How do I tell apt that I want to use my compiled version, and not the repo version?'. I've just issues the command sudo apt-mark hold vim and hopefully tomorrow vim will not be updated again. I've found the command in this question.

  • 1
    grep -i apt /var/log/syslog please. Have you got an automated job that updated your system for you? – roaima Nov 9 '20 at 10:50
  • @roaima Thanks for the tip! Its' the daily apt upgrade. I was not aware that it is running on my machine. – Horror Vacui Nov 9 '20 at 17:13

Please run grep -i apt /var/log/syslog and check for an automated job that updates your system for you. If that exists then it can explain why your own binary is being replaced in the alternatives subsystem. Presumably you want to stop that happening

update-alternatives --config editor 0<&-; echo
There are 4 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path               Priority   Status
* 0            /bin/nano           40        auto mode
  1            /bin/ed            -100       manual mode
  2            /bin/nano           40        manual mode
  3            /usr/bin/vim.nox    40        manual mode
  4            /usr/bin/vim.tiny   15        manual mode

Press <enter> to keep the current choice[*], or type selection number:

If you havent' already done so, install your own binary to the configuration set

update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1

However, if you re-run the --config command (above) you'll see that you have not yet switched to your own binary. Do this and the alternatives subsystem will see a manual selection and should stop changing the setting underneath you. I think this may have been the step you were missing

update-alternatives --set editor /usr/local/bin/vim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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