packer.nvim
packer.nvim copied to clipboard
Feature: Rebuild broken package installations
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 the
runin that block's
use`.
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
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.
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:
- Packer is not handling
run:
correctly all the time - I somehow entered a bad installation state on my system that packer did not return an error from
- Or it was a fluke
For reference, here is my nvim-lua configuration