1

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
  • What does ls -l ~/.vim/ look like? – filbranden Feb 28 at 1:28
  • I'm guessing chmod +x ~/.vim/autoload might resolve at least part of the problem... – filbranden Feb 28 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 – Gabe Santos Feb 28 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 – Gabe Santos Feb 28 at 2:59
1

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.

| improve this answer | |
  • 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 – Gabe Santos Feb 28 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 at 8:33
  • 1
    Seems like it worked! Thanks for your help – Gabe Santos Feb 28 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 at 13:15

Your Answer

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

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