wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.82k stars 266 forks source link

Feature: Rebuild broken package installations #1006

Open jpmcb opened 2 years ago

jpmcb commented 2 years ago

Describe the feature

At times, my nvim packages are (somehow) in a broken state and Packer is unable to recover them elegantly.

An example:

I use telescope-fzf-native.nvim which requires their C code be compiled into a local build/libfzf.so file.

Their recommended Packer configuration is:

use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }

which build the .so file into their build directory, ready to go.

However, if (for some reason) that block was not executed correctly or that loaded module has entered a broken state, _I need a way for packer to completely rebuild that state. In other words, I need a way to re-do therunin that block'suse`.

We can simulate this error state by

rm -rf ~/.local/share/nvim/state/pack/packer/start/telescope-fzf-native.nvim/build

which removes that file, then I get the following error:

Error detected while processing /home/vagrant/.config/nvim/plugin/telescope.lua:
E5113: Error while calling lua chunk: .../start/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: ...k/packer/start/telescope-fz
f-native.nvim/lua/fzf_lib.lua:11: /home/vagrant/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim/lua/../build/libfzf.so: cannot open shared object file: No such fil
e or directory

which make sense since that file no longer exists within the package. I don't see a way for Packer to recover from this state without doing some wonky stuff (like commenting out that configuration, running :PackerClean and PackerCompile, and then un-commenting that block to force a re-download and re-run.)

Proposal:

Something like :PackerRebuild which clears that package state, removes it's compiled lua file, and re-builds and re-downloads everything would be great. Or to scope it down `PackerRebuild would do something similar, but only for a single package.

Again, I do not see a way to get packer to re-do the run: command from above beyond changing my packer configuration file, re-compiling, and re-adding that line.

jpmcb commented 2 years ago

Also, as an aside, i've found myself in this situation upon installation on a new system where it seems the run: make chunk was executed at all and there is no build/ directory, in the local plugin. This makes me think:

For reference, here is my nvim-lua configuration