Error: cannot open .git/FETCH_HEAD: Permission denied

Dear all,

I have the below error during update of our server. Never had this before, can somebody advise what to do?

Already up-to-date.
INFO:bench.app:pulling erpnext
error: cannot open .git/FETCH_HEAD: Permission denied

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 62, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force, reset=reset)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 78, in _update
    pull_all_apps(bench_path=bench_path, reset=reset)
  File "/home/frappe/bench-repo/bench/app.py", line 146, in pull_all_apps
    remote=remote, branch=get_current_branch(app, bench_path=bench_path)), cwd=app_dir)
  File "/home/frappe/bench-repo/bench/utils.py", line 127, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull  upstream master

Thanks in advance for your support.

Regards,
Ahmed

That is mean you don’t have Permission on erpnext folder.
try to change the Permission and try to do update with:

sudo bench update

Thanks for responding.

I tried sudo bench update but I got the exact same error. I don’t recall changing any permissions whatsoever, yet can you guide me on how to check and set permissions for erpnext folder?

Will this help in checking permissions?
root@work:/home/frappe/frappe-bench/apps# ls -l erpnext
total 80
-rw-rw-r-- 1 frappe frappe 200 Apr 20 2015 attributions.md
drwxrwxr-x 32 frappe frappe 4096 Jan 24 03:14 erpnext
drwxrwxr-x 2 frappe frappe 4096 Apr 20 2015 erpnext.egg-info
-rw-r–r-- 1 frappe frappe 34913 Nov 17 03:09 license.txt
-rw-rw-r-- 1 frappe frappe 532 Apr 20 2015 MANIFEST.in
-rw-r–r-- 1 frappe frappe 4620 Jan 5 08:41 README.md
-rw-rw-r-- 1 frappe frappe 17 Apr 20 2015 requirements.txt
-rw-r–r-- 1 frappe frappe 790 Aug 15 05:53 setup.py
-rw-r–r-- 1 frappe frappe 1708 Aug 15 05:53 sponsors.md
drwxrwxr-x 3 frappe frappe 4096 Nov 17 03:09 test_sites
drwxr-xr-x 2 frappe frappe 4096 Aug 15 05:53 travis
root@work:/home/frappe/frappe-bench/apps# stat erpnext
File: ‘erpnext’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd01h/64769d Inode: 1326105 Links: 8
Access: (0775/drwxrwxr-x) Uid: ( 1000/ frappe) Gid: ( 1000/ frappe)
Access: 2017-02-06 12:00:02.915932730 -0500
Modify: 2017-01-05 08:41:27.332952328 -0500
Change: 2017-01-05 08:41:27.332952328 -0500
Birth: -
root@work:/home/frappe/frappe-bench/apps#

error: cannot open .git/FETCH_HEAD: Permission denied

cd /apps/custom_app/

/apps/custom_app/ sudo chown -R frappe .git/