[V7] Bench update non-zero exit error

vhrs@vhrs-HP-Z210-Workstation:~/frappe-bench$ bench clear-cache && bench update
INFO:bench.utils:updating bench
Already up-to-date.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==2.1.0', 'console_scripts', 'bench')()
  File "/home/vhrs/bench-repo/bench/cli.py", line 40, in cli
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/vhrs/bench-repo/bench/commands/update.py", line 49, in update
    version_upgrade = is_version_upgrade()
  File "/home/vhrs/bench-repo/bench/app.py", line 158, in is_version_upgrade
    upstream_version = get_upstream_version(app=app, branch=branch, bench_path=bench_path)
  File "/home/vhrs/bench-repo/bench/app.py", line 204, in get_upstream_version
    branch = get_current_branch(app, bench_path=bench_path)
  File "/home/vhrs/bench-repo/bench/app.py", line 179, in get_current_branch
    return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir)
  File "/home/vhrs/bench-repo/bench/utils.py", line 324, in get_cmd_output
    return subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=open(os.devnull, 'wb')).strip()
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'basename $(git symbolic-ref -q HEAD)' returned non-zero exit status 1

What is your output of command bench --version & bench version on your machine?

vhrs@vhrs-HP-Z210-Workstation:~/frappe-bench$ bench --version
vhrs@vhrs-HP-Z210-Workstation:~/frappe-bench$ bench version
cvhrsian 0.0.1
erpnext 7.0.10
frappe 7.0.2

Dear Frndz…found any solution for this…

@hereabdulla try following and post your feedback

in your case custom username: vhrs / usually default username: frappe

sudo su - vhrs
cd /home/vhrs/bench-repo && git reset --hard && git pull

Then run bench update

Alway remember to run all commands not as root but as frappe or custom username you have chosen while installing bench and erpnext.

Caution: Running commands as root user will lead to various issues due to mixed up permissions.

@yashodhan,thanks for your reply I finally cleared that…