'Why is neovim unable to locate the packer module?
I'm trying to install packer.nvim using the quickstart guide. I cloned the repository using
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
~/.local/share/nvim/site/pack/packer/start/packer.nvim
and created the file ~/.config/nvim/lua/plugins.lua with these contents:
return require('packer').startup(function()
-- Packer can manage itself
use 'wbthomason/packer.nvim'
end)
My ~/.config/nvim/init.vim has only the line lua require('plugins').
When I run nvim I get the following error:
Error detected while processing /home/user/.config/nvim/init.vim:
line 1:
E5105: Error while calling lua chunk: /home/user/.config/nvim/lua/plugins.lua:6: module 'packer' not found:
no field package.preload['packer']
no file '/home/user/.config/nvim/lua/packer.lua'
no file '/home/user/.config/nvim/lua/packer/init.lua'
no file '/etc/xdg/xdg-i3/nvim/lua/packer.lua'
... (many more missing files)
I tried checking my packpath in neovim with :set packpath? but I'm not sure whether it's correct or not.
packpath=~/.config/nvim,/etc/xdg/xdg-i3/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/share/i3/nvi
m/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/var/lib/snapd/desktop/nvim/site,/usr/share/nvim
/runtime,/var/lib/snapd/desktop/nvim/site/after,/usr/share/nvim/site/after,/usr/local/share/nvim/site/a
fter,/usr/share/i3/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,/etc/xdg/xdg-i3/n
vim/after,~/.config/nvim/after
What am I doing wrong?
Solution 1:[1]
I had the same issue, and I found the reason is we run :PackerUpdate/PackerSync and packer.vim was removed by itself.
This is my solution:
- Clone the packer and install it again.
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
~/.local/share/nvim/site/pack/packer/start/packer.nvim
- Make sure the packer.vim itself is included in startup config block
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- this is essential.
...your config...
end)
- Now you can run
:PackerUpdate/PackerSyncin nvim again and everything works fine.
Solution 2:[2]
Solved it by reloading whole nvim.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kinso |
| Solution 2 | Mykytak |
