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 ~/.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?

2

2 Answers

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:

  1. Clone the packer and install it again.
git clone --depth 1 ~/.local/share/nvim/site/pack/packer/start/packer.nvim
  1. 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)
  1. Now you can run :PackerUpdate/PackerSync in nvim again and everything works fine.
1

Solved it by reloading whole nvim.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like