Bench update error ERROR: Command 'git symbolic-ref -q

error during bench update

I have two apps installed
Frappe and LMS

Command Output :

$ bench update
ERROR: Command ‘git symbolic-ref -q --short HEAD’ returned non-zero exit status 1.
Traceback (most recent call last):
File “/home/lms/.local/bin/bench”, line 8, in
sys.exit(cli())
^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/cli.py”, line 132, in cli
bench_command()
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/commands/update.py”, line 59, in update
update(
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/bench.py”, line 457, in update
validate_branch()
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/bench.py”, line 644, in validate_branch
branch = get_current_branch(app)
^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/app.py”, line 175, in get_current_branch
return get_cmd_output(“git symbolic-ref -q --short HEAD”, cwd=repo_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/lms/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/init.py”, line 237, in get_cmd_output
output = subprocess.check_output(
^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command ‘git symbolic-ref -q --short HEAD’ returned non-zero exit status 1.

Solved

Apps updated

How you solved this problem ?

i have bench version 5.22.9 and want to update only custom app.

if you only want to update one app then go to the directory of the app

frappe-bench>apps>custom app

then use git pull command to update the app

after that use

bench build

then

bench migrate

i want to get update from custom-app without using git is it possible ?

No , If you only want to update one app then you must do git pull from the specific app folder
or if you want to update all apps then can run

bench update

this command will pull latest version from git of all apps and update them to latest version

if i am doing bench update then also this error occurs

The error usually indicates that one or more of your repositories are in a “detached HEAD” state, meaning they are not on any active branch.

check each app for detached head using command

cd [app_name]
git status

then switch to a active branch

git checkout [branch_name]

then retry the update

bench update

Thanks It works