Skip to content

[audit] Prune orphaned vim.pack plugins so removed entries stay removed#304

Merged
stanfish06 merged 1 commit into
masterfrom
audit/prune-orphaned-vim-pack-plugins
Jul 14, 2026
Merged

[audit] Prune orphaned vim.pack plugins so removed entries stay removed#304
stanfish06 merged 1 commit into
masterfrom
audit/prune-orphaned-vim-pack-plugins

Conversation

@stanfish06

Copy link
Copy Markdown
Owner

What

nvim-web-devicons was removed from nvim-pack-lock.json by #285 (merged), because mini.icons now mocks it and it's no longer in package_list. It reappeared in the lock file a few commits later (3a4f957bbb40aa) and is back as of today.

Where

lua/config/plugins.lua:74-79 (the vim.pack branch of sync_packages())

Why it matters

vim.pack.add(package_list) only registers the plugins currently in package_list. It never deletes a plugin that drops out of the list — the on-disk clone (under the gitignored pack/ dir) just becomes "inactive". vim.pack.get() still reports it, and the subsequent vim.pack.update(nil, {...}) call re-syncs the lock file against everything vim.pack knows about, so the stale entry gets written straight back in. #285's fix could only ever last until the next sync — it edited the symptom (the lock file) rather than the cause (vim.pack never being told to drop the package).

This isn't specific to nvim-web-devicons: any plugin removed from package_list in the future will silently keep reappearing in the lock file the same way, since nothing ever calls vim.pack.del().

Fix

After vim.pack.add(package_list), find packages vim.pack.get() reports as not active (i.e. no longer in package_list) and vim.pack.del() them before vim.pack.update() runs:

local inactive = vim.iter(vim.pack.get())
    :filter(function(pkg) return not pkg.active end)
    :map(function(pkg) return pkg.spec.name end)
    :totable()
if #inactive > 0 then
    print("Prune orphaned: " .. table.concat(inactive, ", "))
    vim.pack.del(inactive)
end

Also removes the now-genuinely-stale nvim-web-devicons entry from nvim-pack-lock.json one more time — this time it should stick since the pruning step runs before the next auto-sync.

Mechanical, low-risk change scoped to the vim.pack sync path only; the legacy git-clone fallback path is untouched.


Generated by Claude Code

nvim-web-devicons was manually stripped from the lock file in #285, but
vim.pack never deletes packages left on disk when they drop out of
package_list -- it just marks them inactive. The next vim.pack.update()
call re-discovered the stale clone and wrote its lock entry right back,
which is why it reappeared over the following days of auto-sync commits.

sync_packages() now calls vim.pack.del() on any inactive package after
vim.pack.add(), so removing an entry from package_list actually removes
it going forward instead of being silently reverted on the next sync.
@stanfish06 stanfish06 merged commit 9c9df34 into master Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants