Fixing the 'trying to overwrite' error when updating a GNU/Linux system via apt/apt-get

I recently ran into an issue upgrading a Ubuntu 18.04-powered server I run. I usually run the following command:

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove && sudo apt-get autoclean && sudo apt list --upgradable && df -h && sudo service nginx reload

but it failed trying to install, of all things, an upgrade 'vim-tiny' package with an error:

dpkg: error processing archive /var/cache/apt/archives/vim-tiny_2%3a8.0.1453-1ubuntu1.7_amd64.deb (--unpack):
trying to overwrite '/usr/share/vim/vim80/doc/help.txt', which is also in package vim-runtime 2:8.0.1453-1ubuntu1.7
Errors were encountered while processing:
/var/cache/apt/archives/vim-tiny_2%3a8.0.1453-1ubuntu1.7_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I was stuck. A quick search suggested that I try the command:

sudo apt --fix-broken  install

but that didn't work either, failing with precisely the same error as above.

Finally, after much searching, I found the right answer:

sudo dpkg --configure --force-overwrite -a

I hope this helps someone!

 

 

Add new comment

Note to commenters: due to problems with spam comments, your comment will only appear on this site after it's been deemed (by me) to be legitimate.