4

On Macbook Pro, Terminal, standard Vim, VimPlug

When I start vim I get the following message:

Error detected while processing /Users/me/.vimrc:
line 159:
E117: Unknown function: plug#begin

In my .vimrc I have the following:

call plug#begin('~/.vim/plugged')
[a bunch of plugins]
call plug#end()

As far as I can tell the setup is correct but vim doesn't recognize the function so it can't load any of my plugins. Everything was working before. I figured this has something to do with the plug.vim in ~/.vim/autoload. However when I try to access the autoload directory I get this error:

cd: permission denied: autoload

This might explain why vim isn't able to call the plug#begin function, but I don't know how to fix it.

UPDATE: Output of ls -l ~/.vim:

total 0
drwxr-x---    5 root  wheel    160 Feb 27 10:27 autoload
drwxr-xr-x    8 gabe  staff    256 Nov 27 14:40 colors
drwxr-xr-x   30 gabe  staff    960 Feb 27 10:19 plugged
drwxr-xr-x  370 gabe  staff  11840 Feb 27 17:13 view
6
  • What does ls -l ~/.vim/ look like?
    – filbranden
    Feb 28, 2020 at 1:28
  • I'm guessing chmod +x ~/.vim/autoload might resolve at least part of the problem...
    – filbranden
    Feb 28, 2020 at 1:29
  • @filbranden total 0 total 0 drwxr-x--- 5 root wheel 160 Feb 27 10:27 autoload drwxr-xr-x 8 gabe staff 256 Nov 27 14:40 colors drwxr-xr-x 30 gabe staff 960 Feb 27 10:19 plugged drwxr-xr-x 370 gabe staff 11840 Feb 27 17:13 view Feb 28, 2020 at 2:57
  • @filbranden when i try chmod i get this: chmod: Unable to change file mode on /Users/gabe/.vim/autoload: Operation not permitted Feb 28, 2020 at 2:59
  • I have the exact same issue. I try to reload the file with the :source % it gives me the same error then try to save and exit file and try to reload the file with source command again it gives the same error but when I try to open vim editor through vim command and try to run :PlugIntall its work for me. Dec 1, 2020 at 20:03

1 Answer 1

4

Looks like you created the autoload directory (or ran the wget command to install vim-plug) under sudo.

Running it under sudo will be bad because it will create files and directories that only root will be able to access!

To fix that now:

$ sudo chown -Rh gabe:staff ~/.vim
$ chmod -R a+rX,u+w,go-w ~/.vim

This should reset the ownership of all the files and directories under .vim to your user.

It will also reset the file permissions to their default. Not strictly necessary, but cleaner that way.

5
  • 1
    the second line doesn't work, chmod: Invalid file mode: a=rX, but the first one did and it looks like i can access the file again Feb 28, 2020 at 7:12
  • @Gabe Hmmm, MacOS. Does this work? a+rX,u+w,go-w for the middle argument with the mode...
    – filbranden
    Feb 28, 2020 at 8:33
  • 1
    Seems like it worked! Thanks for your help Feb 28, 2020 at 8:38
  • @Gabe If this solved your problem, please accept the answer. See the help topic on what to do with answers. Thanks!
    – filbranden
    Feb 28, 2020 at 13:15
  • 1
    Thanks a lot! It worked;)
    – Max
    Sep 3, 2020 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.