I'm writing a Makefile to sync my local dotfiles with GitHub. I recently decided to also add my .vim folder to the repo. But when trying to copy the .vim folder I keep getting a Permission denied error.
The line in the Makefile that should copy the folder is:
@$(foreach file, $(FILES), echo "Copying $(BASH_DIR)$(file) to ."; cp -R $(BASH_DIR)$(file) . ; )
The permissions for the .vim folder is drwxr-xr-x, and the error message I get is:
cp: ./.vim/bundle/editorconfig-vim/.git/objects/pack/pack-bbb66dd84e2bdd3b05e19454b0800a928ecb94db.idx: Permission denied
cp: ./.vim/bundle/editorconfig-vim/.git/objects/pack/pack-bbb66dd84e2bdd3b05e19454b0800a928ecb94db.pack: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/4d/e66757eebe4798eaaf02e3762a152d283eca81: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/58/165f0e58211f8a5910df65414cc637651f046a: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/6e/e90f3cfbd7c4956892da49896f62614448f851: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/fc/161ff6515d405831c65c608d63627aa60c4066: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/pack/pack-182ea16d08e5b471d5ce5f545f599f24ebe306cf.idx: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/pack/pack-182ea16d08e5b471d5ce5f545f599f24ebe306cf.pack: Permission denied
cp: ./.vim/bundle/vim-jade/.git/objects/pack/pack-20254027167dcc621463c4454ed0fc539cf0b1da.idx: Permission denied
cp: ./.vim/bundle/vim-jade/.git/objects/pack/pack-20254027167dcc621463c4454ed0fc539cf0b1da.pack: Permission denied
cp: ./.vim/bundle/vim-markdown/.git/objects/pack/pack-b18aa89f38b322d622d05d969a9df41915bf9ea8.idx: Permission denied
cp: ./.vim/bundle/vim-markdown/.git/objects/pack/pack-b18aa89f38b322d622d05d969a9df41915bf9ea8.pack: Permission denied
Does anyone know how I can get this to work? Preferably without having to change permissions manually.
@vonbrand I am trying to add my vim setup to my dotfiles for easy access on other terminals. I am using pathogen to handle my vim plugins. They are handled by cloning the plugins into the .vim/bundles directory. When I try to cp -r .vim into my dotfiles folder I get the error above. I'd like to find some solution for having these repos as a part of my dotfiles folder without having to manually change the permissions, as this would force me to repeat that process each time I decided to add or change a plugin. I don't know if the solution I'm looking for is passing some option to cp, or using some other tool for copying or syncing the .vim directory, or if chown is the only option I have.
ls -ld ~/.vim/bundle/vim-jade/.git returns drwxr-xr-x 12 $USER staff 408 Jan 21 15:26 ~/.vim/bundle/vim-jade/.git

chmod -R u+rwX ~/.vimsuch that you can write to all files/directories there. If it fails, you do not own all files and need to runchown -R YOURUSERNAME ~/.vimas root. – jofel Jan 22 at 9:48.vimcontains a bunch of git repositories on its own. Is the user doing the git stuff in .vim somebody other than you perhaps? What does e.g.ls -ld .vim/bundle/vim-jade/.gitreturn? – vonbrand Jan 22 at 9:55gitcontrol, you don't want the.gitdirectory inside.vim. You should exclude it. You could us the BASH builtincp -r !(exclude_me)to do that. – htor Jan 22 at 10:46.gitdirectory. Are you sure you aren't looking forgit push? – Gilles Jan 22 at 22:52