1

I'm new to vim. The problem happens when I type :PlugInstall I get:

[vim-plug] Invalid plug directory: /Users/joqsan/.vim/plugged. Try to call plug#begin with a valid directory

This is how I installed vim-plug:

$ mkdir -p ~/.vim/autoload/ $ cd ~/.vim/autoload/
$ curl -O https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

In .vimrc I have:

set number

if filereadable(expand("~/.vimrc.plug"))
source ~/.vimrc.plug
endif

In ~/.vimrc.plug:

call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
call plug#end()

But when I reload vim and type :PlugInstall, I get:

[vim-plug] Invalid plug directory: /Users/joqsan/.vim/plugged. Try to call plug#begin with a valid directory

If I type :scriptnames I get this:

1: /usr/share/vim/vimrc
2: ~/.vimrc
3: ~/.vimrc.plug
4: ~/.vim/autoload/plug.vim
5: /usr/share/vim/vim80/filetype.vim
6: /usr/share/vim/vim80/ftplugin.vim
7: /usr/share/vim/vim80/indent.vim
8: /usr/share/vim/vim80/syntax/syntax.vim
9: /usr/share/vim/vim80/syntax/synload.vim
10: /usr/share/vim/vim80/syntax/syncolor.vim
11: /usr/share/vim/vim80/plugin/getscriptPlugin.vim
12: /usr/share/vim/vim80/plugin/gzip.vim
13: /usr/share/vim/vim80/plugin/logiPat.vim
14: /usr/share/vim/vim80/plugin/manpager.vim
15: /usr/share/vim/vim80/plugin/matchparen.vim
16: /usr/share/vim/vim80/plugin/netrwPlugin.vim
17: /usr/share/vim/vim80/plugin/rrhelper.vim
18: /usr/share/vim/vim80/plugin/spellfile.vim
19: /usr/share/vim/vim80/plugin/tarPlugin.vim
20: /usr/share/vim/vim80/plugin/tohtml.vim
21: /usr/share/vim/vim80/plugin/vimballPlugin.vim
22: /usr/share/vim/vim80/plugin/zipPlugin.vim

Since I don't see ~/.vim/plugged, I try to create the directory:

$ mkdir ~/.vim/plugged

But I get:

net120:~ joqsan$ mkdir ~/.vim/plugged
mkdir: /Users/joqsan/.vim/plugged: File exists
net120:~ joqsan$ 

I don't know what I'm doing wrong.

Edit 1: Directory structure of ~/.vim and ~/.vim/autoload

net120:~ joqsan$ ls -la ~/.vim/autoload
total 256
drwxr-x---  3 root  staff     96 Mar 30 12:33 .
drwxr-x---  4 root  staff    128 Mar 30 13:14 ..
-rw-r--r--  1 root  staff  74434 Mar 30 13:45 plug.vim

Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim
total 0
drwxr-x---   4 root    staff   128 Mar 30 13:14 .
drwxr-xr-x+ 66 joqsan  staff  2112 Mar 30 17:38 ..
drwxr-x---   3 root    staff    96 Mar 30 12:33 autoload
-rw-r--r--   1 root    staff     0 Mar 30 13:14 plugged`

Edit 2:

enter image description here


Edit 3:

On OS X, the primary group is always staff, so I think this is ok. I didn't create the directory ~/.vim. I installed vim with homebrew (I mean, I did nothing manually).

After doing what you recommended I got this:

Joqsans-MacBook-Air:~ joqsan$ sudo chown joqsan:staff ~/.vim
Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim
total 0
drwxr-x---   4 joqsan  staff   128 Mar 30 23:08 .
drwxr-xr-x+ 67 joqsan  staff  2144 Mar 31 04:28 ..
drwxr-x---   3 root    staff    96 Mar 30 12:33 autoload
drwxr-xr-x   2 root    staff    64 Mar 30 23:08 plugged

With respect to the previous prompt (in Edit 1 above) now the first two directories are owned by joqsan, but I still get the error when typing :PlugInstall. Maybe that is because autoload and plugged are still owned by root?


Edit 4:

Joqsans-MacBook-Air:~ joqsan$ sudo chown -R joqsan: ~/.vim
Joqsans-MacBook-Air:~ joqsan$ ls -al ~/.vim
total 0
drwxr-x---   4 joqsan  staff   128 Mar 30 23:08 .
drwxr-xr-x+ 67 joqsan  staff  2144 Mar 31 13:11 ..
drwxr-x---   3 joqsan  staff    96 Mar 30 12:33 autoload
drwxr-xr-x   2 joqsan  staff    64 Mar 30 23:08 plugged

enter image description here

Any help would be appreciated.

9
  • What happens if you run $ mkdir /Users/joqsan/.vim/plugged in your shell? If you get a “Permission denied” error message, try to change the owner of the ~/.vim/ directory by running $ chown joqsan:joqsan /Users/joqsan/.vim.
    – user938271
    Mar 30, 2019 at 14:00
  • Relevant code: github.com/junegunn/vim-plug/blob/…
    – D. Ben Knoble
    Mar 30, 2019 at 14:03
  • @klaus I did that and it seems that everything is ok. I mean, no error is reported (above posted what appears).
    – asd
    Mar 30, 2019 at 14:40
  • @user938271 Above posted what appear when using mkdir: mkdir: /Users/joqsan/.vim/plugged: File exists
    – asd
    Mar 30, 2019 at 14:42
  • 3
    It seems you have a file where vim-plug wants to create a directory. Make a backup in case it contains important data, and move it: $ mv /Users/joqsan/.vim/plugged /Users/joqsan/.vim/plugged.bak. Then try again to create the directory: $ mkdir /Users/joqsan/.vim/plugged.
    – user938271
    Mar 30, 2019 at 14:46

1 Answer 1

1

As posted in the comments:

You have a file where vim-plug wants to create a directory

Create a back up and get it out of the way:

mv ~/.vim/plugged ~/.vim/plugged.bak

Then try again.

Also make sure you own the directory:

sudo chown $USER: ~/.vim

The vim directory can become owned by root if you use sudo vim—the correct technique is to set the EDITORor VISUAL variable and invoke sudoedit.

12
  • When I do that I got: mv: rename /Users/joqsan/.vim/plugged to /Users/joqsan/.vim/plugged.bak: Permission denied. To handle this do I have to do it with sudo` or try to change the owner as suggested in the comments?
    – asd
    Mar 30, 2019 at 19:54
  • You ought to change the owner there... if you don’t have permissions there’s something even wonkier going
    – D. Ben Knoble
    Mar 30, 2019 at 20:07
  • In your output of ls I see that you're working on two separate machines from 2 different users. First of all, don't use sudo for anything related to plugins, it shouldn't require that. And also from output of ls command I see that the whole ~/.vim folder is chowned by root user of staff group. Did you create it with sudo? If so, just chown it back to your own user with sudo chown username:username ~/.vim. You'd need sudo here to take back what's yours. Unless, this is actually your work computer. Maybe that's why there is a usergroup named staff?!
    – 3N4N
    Mar 30, 2019 at 20:29
  • 1
    @D.BenKnoble, I'm concerned over the sudo thing. That's why I suggested a little research. But it should solve the problem, isn't it?
    – 3N4N
    Mar 31, 2019 at 3:28
  • 1
    @klaus Yep, it's fixed. Thank you both for taking the time to help me with this. I'll be more careful with that sudo thing.
    – asd
    Mar 31, 2019 at 13:04

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.