init.lua icon indicating copy to clipboard operation
init.lua copied to clipboard

E492: Not an editor command: PackerSync

Open Jubijub opened this issue 2 years ago • 7 comments

Issue : upon relaunching nvim, commands like :PackerSync show the error message : "E492: Not an editor command: PackerSync" Going to /lua/[your_name]/packer.lua and :so the file fixes the issue, so I figured this packer.lua never gets loaded.

I did compare my setup to this very config and have the same settings, but I think I found a possible cause : in /lua/[your_name]/init.lua, we actively require the packages [your_name].remap and [your_name].set, but we never require [your_name].packer

I tried adding this to my /lua/[your_name]/init.lua and the problem goes away.

require("jubi.remap")
require("jubi.set")
require("jubi.packer")

Jubijub avatar Jan 09 '23 20:01 Jubijub

because it not suppose to run everytime. Like I will only run packer when I need to update something. go to packer.lua :so :PackerSync.

subarutendou avatar Jan 09 '23 20:01 subarutendou

While I agree with the idea, this is not easily understood if one hasn't watched the video. Maybe a small comment or so in lua/theprimeagen/init.lua or packer.lua could clarify this a little bit.

svenXY avatar Jan 12 '23 13:01 svenXY

Maybe is normal for vim user, bucause this action take no though. Is like the basic configuration step in my mind. Setting up zsh is like this too, config then sourse the file if I don’t want to relaunch the terminal.

subarutendou avatar Jan 12 '23 13:01 subarutendou

Note to anyone having issues loading files: I'd double check your file configuration, ensuring files and folders are all where they are supposed to be. I'd also suggest adding

local filename = function()
  local str = debug.getinfo(2, "S").source:sub(2)
  return str:match("^.*/(.*).lua$") or str
end
print(filename());

to each *.lua for debugging.

H4ppy-04 avatar Jan 13 '23 01:01 H4ppy-04

because it not suppose to run everytime. Like I will only run packer when I need to update something. go to packer.lua :so :PackerSync.

What is the benefit of NOT sourcing packer.lua ? on a modern computer I doubt this slows down nvim that much (mine does start instantly still), and that means I can simply do :PackerSync to update my plugins. What is the benefit of the extra friction ?

In any case, it could be worth documenting somewhere that this is required, as it's not obvious from watching the video.

Jubijub avatar Jan 13 '23 17:01 Jubijub

I don't think there really is a benefit not to sourcing it, I'd also use the autobootstrapping feature so packer can install itself XD

jaitaiwan avatar Jan 24 '23 02:01 jaitaiwan

I get why some would argue it shouldn't be sourced. If so, however, it'd be good if people teaching how to use packer would note that this is a thing. I am sure we have not been the first people to stumble across this issue and be confused.

I am happy this issue/ticket is here, it stops me wondering what is wrong with my setup.

zaddok avatar Jun 27 '23 23:06 zaddok