Failed Vim Upgrade: Reinstall System Runtime vs. Restore Full Backup to Avoid Mixing Plugin Versions
0 reputation · 19 Nov 2023, 23:22 UTC
0 reputation · 19 Nov 2023, 23:22 UTC
After a failed Vim upgrade on Vim 8.2 or later, the system runtime directory ($VIMRUNTIME) may contain a mix of old and new files, while the user directory (~/.vim) usually remains untouched. The goal is to return to a consistent state without introducing subtle plugin incompatibilities. One documented approach is to reinstall the Vim package or rebuild from source, which overwrites system files but preserves personal plugins and settings. The alternative is to restore a full backup of the previous runtime, including both $VIMRUNTIME and ~/.vim, returning to a known-good state at the cost of losing any changes made after the backup.
The uncertainty lies in whether preserving ~/.vim is safer than forcing a clean system runtime, especially when plugins depend on new Vim script features or API changes introduced between minor versions. Both paths require verifying the active version and loaded scripts afterward.
Which recovery strategy minimizes version mismatches when the upgrade failure leaves $VIMRUNTIME inconsistent? Does reinstalling the system package while keeping ~/.vim risk enough plugin incompatibility to favor a full runtime restore? How should the choice change if local modifications exist in system runtime files after the backup was taken?
33275 reputation · 20 Nov 2023, 05:18 UTC
Reinstall or rebuild the Vim package so the executable and $VIMRUNTIME come from the same build, and keep your existing ~/.vim. A full restore of both $VIMRUNTIME and ~/.vim is safer only when that backup is the exact state you want to return to and losing later changes is acceptable.
After a failed upgrade, the most likely inconsistency is inside $VIMRUNTIME: some files may be from the old package while the binary is new, or vice versa. Because ~/.vim is normally additive and sits earlier in &runtimepath, preserving it during a package reinstall usually does not reintroduce the same class of mismatch. Restoring an old ~/.vim alongside a newer binary, however, recreates the mismatch in reverse and can hide the original failure.
Choose the full backup only if:
$VIMRUNTIME and ~/.vim pair.If the backup was taken after the failed upgrade, it may already contain mixed files; restoring it blindly would not fix the inconsistency.
Do not copy an old $VIMRUNTIME over a newer one, and do not assume a package reinstall preserves local edits—conffile and overwrite policies vary by distribution. Instead:
~/.vim/after or another user runtimepath entry rather than editing $VIMRUNTIME directly.Run vim --version and check :version inside Vim. If the installed binary is not the version you intend to run, the recommendation flips: force the exact package version or rebuild that version first, then reconcile plugins. If the binary is correct but the runtime is suspect, reinstall the matching package and keep ~/.vim.
Confirm the active version and loaded scripts:
vim --version
vim -u NONE -N -c 'echo $VIMRUNTIME' -c 'echo &runtimepath' -c 'qa!'
Then start normally and inspect :scriptnames and :messages for sourcing errors, duplicate plugin loads, or help-tag complaints. Exercise plugins that depend on newer script or API features in a scratch file. If they pass under vim --clean but fail with your configuration, the issue is plugin/config rather than runtime consistency.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.