diff options
| author | Evgeni Chasnovski <evgeni.chasnovski@gmail.com> | 2025-10-07 22:24:23 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-07 12:24:23 -0700 |
| commit | 3b860653ca0c698629d714f3af996822335debd1 (patch) | |
| tree | 2b34b4b3344952eabcb3ab20c7f9b5cb0b355199 /runtime/lua/vim/pack.lua | |
| parent | 006101360d6fbcadfe7c8d030f1d66cfcaf34951 (diff) | |
| download | rneovim-3b860653ca0c698629d714f3af996822335debd1.tar.gz rneovim-3b860653ca0c698629d714f3af996822335debd1.tar.bz2 rneovim-3b860653ca0c698629d714f3af996822335debd1.zip | |
fix(pack): handle lockfile in case of install errors #36064
Problem: If plugin was intended to install but there were errors (like
if there is a typo in `src`), lockfile still includes its entry.
This leads to all source of problems (like not correct `get()` output,
not working `update()`, etc.).
Solution: Explicitly account for plugins that were not installed.
Alternative solution might be to write a safe
`lock_set(plug, field, value)` wrapper (which sets field for a correct
`plugins` entry in the lockfile Lua table) and use it after install
to detect the change in `version`. However, this always requires
an extra pass through plugins on every startup, which is suboptimal.
Optimizing for the "happy path" should be a priority in `add()`.
Diffstat (limited to 'runtime/lua/vim/pack.lua')
| -rw-r--r-- | runtime/lua/vim/pack.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index b7e396febe..532c85c5fe 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -789,6 +789,11 @@ function M.add(specs, opts) if #plugs_to_install > 0 then git_ensure_exec() install_list(plugs_to_install, opts.confirm) + for _, p in ipairs(plugs_to_install) do + if not p.info.installed then + plugin_lock.plugins[p.spec.name] = nil + end + end end if needs_lock_write then |