Update error: subprocess.CalledProcessError

When i run bench update

i get the following error

Please tell me how to bypass this error and update the erpnext.

erpnext@erpnext-vm:~/frappe-bench$ bench update
From GitHub - frappe/shopping_cart: Online Shopping Cart integrated with ERPNext

  • branch HEAD → FETCH_HEAD
    Already up-to-date.
    From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
  • branch HEAD → FETCH_HEAD
    Updating 383a1e9…020cae1
    error: Your local changes to the following files would be overwritten by merge:
    frappe/init.py
    frappe/version.py
    frappe/cli.py
    frappe/core/doctype/customize_form/customize_form.js
    frappe/core/doctype/user/user.js
    frappe/core/doctype/user/user.py
    frappe/core/page/data_import_tool/data_import_tool.js
    frappe/core/page/data_import_tool/data_import_tool.py
    frappe/core/page/data_import_tool/exporter.py
    frappe/core/page/data_import_tool/importer.py
    frappe/core/page/modules_setup/modules_setup.js
    frappe/core/page/permission_manager/permission_manager.js
    frappe/core/page/user_permissions/user_permissions.js
    frappe/hooks.py
    frappe/installer.py
    frappe/model/db_schema.py
    frappe/model/document.py
    frappe/public/css/desk.css
    frappe/public/js/frappe/form/assign_to.js
    frappe/public/js/frappe/form/comments.js
    frappe/public/js/frappe/form/grid.js
    frappe/public/js/frappe/form/infobar.js
    frappe/public/js/frappe/ui/editor.js
    frappe/public/js/frappe/ui/filters.js
    frappe/public/js/frappe/ui/messages.js
    frappe/public/js/frappe/ui/toolbar/toolbar.js
    frappe/public/js/frappe/views/query_report.js
    frappe/sessions.py
    frappe/templates/emails/new_user.html
    frappe/templates/emails/password_reset.html
    frappe/templates/emails/password_update.html
    frappe/templates/form_grid/fields.html
    frappe/templates/generators/web_form.html
    frappe/templates/includes/breadcrumbs.html
    frappe/templates/includes/comment.html
    frappe/templates/includes/comments.html
    frappe/templates/includes/comments.py
    frappe/templates/includes/sidebar.html
    frappe/templates/pages/404.html
    frappe/templates/pages/list.html
    frappe/templates/pages/list.py
    frappe/templates/pages/update-password.html
    frappe/utils/install.py
    frappe/utils/jinja.py
    frappe/utils/user.py
    frappe/website/context.py
    frappe/website/doctype/web_page/web_page.py
    frappe/website/js/website.js
    frappe/website/render.py
    frappe/website/statics.py
    frappe/website/template.py
    frappe/website/utils.py
    frappe/website/website_generator.py
    frappe/widgets/form/assign_to.py
    setup.py
    test_sites/test_site/site_config.json
    Please, commit your changes or stash them before you can merge.
    Aborting
    Error: None
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 9, in
    load_entry_point(‘bench==0.1’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/bench-repo/bench/cli.py”, line 29, in cli
    return bench()
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 610, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 590, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 416, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/bench-repo/bench/cli.py”, line 124, in update
    pull_all_apps()
    File “/home/frappe/bench-repo/bench/app.py”, line 64, in pull_all_apps
    exec_cmd(“git pull {rebase} upstream HEAD”.format(rebase=rebase), cwd=app_dir)
    File “/home/frappe/bench-repo/bench/utils.py”, line 59, in exec_cmd
    subprocess.check_call(cmd, cwd=cwd, shell=True)
    File “/usr/lib/python2.7/subprocess.py”, line 511, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘git pull upstream HEAD’ returned non-zero exit status 1

as the error says, you’ve uncommited changes to a lot of files in apps/frappe repo. Have you changed these files?

I didn’t change anything.

All the changes i did it was from graphical interface like (custom fields)

How can i can discard this changes to default?

To revert changes,

cd ~/frappe-bench
cd apps/frappe
git reset --hard
cd -
bench update
1 Like

Thanks

I have tried to run the above commands as erpnext user but problem still remain the same.

erpnext@erpnext-vm:~/frappe-bench/apps/frappe$ git reset --hard
HEAD is now at 383a1e9 Merge pull request #882 from pdvyas/fix-mariadb
erpnext@erpnext-vm:~/frappe-bench/apps/frappe$ cd -
/home/erpnext/frappe-bench
erpnext@erpnext-vm:~/frappe-bench$ bench update
From GitHub - frappe/shopping_cart: Online Shopping Cart integrated with ERPNext

  • branch HEAD → FETCH_HEAD
    Already up-to-date.
    From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
  • branch HEAD → FETCH_HEAD
    Updating 383a1e9…226fc9c
    error: unable to unlink old ‘frappe/website/doctype/web_form/web_form.json’ (Permission denied)
    error: unable to unlink old ‘frappe/website/doctype/web_form/web_form.py’ (Permission denied)
    Error: None
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 9, in
    load_entry_point(‘bench==0.1’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/bench-repo/bench/cli.py”, line 29, in cli
    return bench()
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 610, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 590, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 416, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/bench-repo/bench/cli.py”, line 124, in update
    pull_all_apps()
    File “/home/frappe/bench-repo/bench/app.py”, line 64, in pull_all_apps
    exec_cmd(“git pull {rebase} upstream HEAD”.format(rebase=rebase), cwd=app_dir)
    File “/home/frappe/bench-repo/bench/utils.py”, line 59, in exec_cmd
    subprocess.check_call(cmd, cwd=cwd, shell=True)
    File “/usr/lib/python2.7/subprocess.py”, line 511, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘git pull upstream HEAD’ returned non-zero exit status 1

did you, by mistake ever update as root before because it seems that git is not able to remove the files.

su # enter root password, default is erpnext
cd /home/erpnext/frappe-bench/apps
chown -R erpnext frappe

then try the update again. Reset hard again if necessary…

Thank you for your prompt response.

Most probably i run update as root that was my mistake.

I followed your instructions but the issue still remain. Any advice?

root@erpnext-vm:/home/erpnext/frappe-bench/apps# chown -R erpnext frappe
erpnext@erpnext-vm:~/frappe-bench/apps/frappe$ git reset --hard
HEAD is now at 383a1e9 Merge pull request #882 from pdvyas/fix-mariadb

are you getting the permission denied for frappe, maybe you need to fix ownership for other directories also.

are you getting the permission denied for frappe, maybe you need to fix ownership for other directories also.

Can you advice me how to to do that?

su # enter root password, default is erpnext
cd /home/erpnext/frappe-bench/apps
chown -R erpnext * # become erpnext again
exit
cd /home/erpnext/frappe-bench/apps
for repo in *; do cd $repo && pwd && git reset --hard && cd -; done

Thank you so much that’s work

Last command should be with out quote (") at the end

for repo in *; do cd $repo && pwd && git reset --hard && cd -; done

1 Like