Bench update issues - Insufficient permissions

Hi,

Am facing this issue with when I am trying to run bench update. Can you please help?

INFO:bench.utils:updating bench
INFO:bench.utils:git pull
error: refs/stash does not point to a valid object!
error: refs/stash does not point to a valid object!
error: refs/stash does not point to a valid object!
error: refs/stash does not point to a valid object!
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 4), reused 3 (delta 1), pack-reused 0
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/update.py”, line 35, in update
update_bench()
File “/home/frappe/.bench/bench/utils.py”, line 229, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/utils.py”, line 130, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

cd /home/frappe/.bench
git reset --hard
git pull

If you still get insufficient permission error, try running sudo git pull instead.

Also check that you haven’t previously run bench update as root as this will mean parts of frappe-bench are owned by root and then can’t be written to afterwards as frappe user