V4 bench update gives error

Hi,

In v4 production setup, bench update command resulted an error.

nescode@Nescodeerpnext:~/frappe-bench$ bench update
Already up-to-date.
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
From https://github.com/frappe/frappe
   2325753..19ce1a7  master     -> upstream/master
   0a661ff..19ce1a7  v4.x.x     -> upstream/v4.x.x
 * [new tag]         v4.14.0    -> v4.14.0
From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Updating 2325753..19ce1a7
Fast-forward
 frappe/__version__.py                              |  2 +-
 frappe/hooks.py                                    |  2 +-
 frappe/public/css/font/noto_sans/noto_sans.css     | 24 +++++++++++-----------
 frappe/public/js/frappe/misc/number_format.js      |  9 +++++---
 .../templates/print_formats/standard_macros.html   |  2 +-
 frappe/website/utils.py                            |  2 +-
 setup.py                                           |  2 +-
 7 files changed, 23 insertions(+), 20 deletions(-)
From https://github.com/frappe/shopping-cart
 * branch            master     -> FETCH_HEAD
Already up-to-date.
remote: Counting objects: 42, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 42 (delta 34), reused 17 (delta 9), pack-reused 0
Unpacking objects: 100% (42/42), done.
From https://github.com/frappe/erpnext
 * branch            master     -> FETCH_HEAD
   9490d9d..92b253d  master     -> upstream/master
Updating 9490d9d..92b253d
Fast-forward
 erpnext/__version__.py                             |  2 +-
 .../doctype/sales_invoice/sales_invoice.py         |  9 +++--
 .../accounts_receivable/accounts_receivable.py     | 16 ++++-----
 .../received_items_to_be_billed.json               |  4 +--
 .../doctype/purchase_order/purchase_order.py       | 11 ++++++
 erpnext/hooks.py                                   |  2 +-
 erpnext/patches.txt                                |  4 ++-
 .../delete_gl_entries_for_cancelled_invoices.py    | 13 +++++++
 erpnext/patches/v4_2/fix_recurring_orders.py       | 41 ++++++++++++++++++++++
 erpnext/selling/doctype/sales_order/sales_order.py | 11 ++++++
 erpnext/selling/sales_common.js                    |  2 +-
 setup.py                                           |  2 +-
 12 files changed, 100 insertions(+), 17 deletions(-)
 create mode 100644 erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
 create mode 100644 erpnext/patches/v4_2/fix_recurring_orders.py
database backup taken - ./site1.local/private/backups/20150418_34092648_database.sql.gz - on 2015-04-18 17:12:35.994248

Running latest for site1.local
--------------------------------------------------
Executing erpnext.patches.v4_2.fix_recurring_orders in site1.local (1bd3e0294d)
Success
Executing erpnext.patches.v4_2.delete_gl_entries_for_cancelled_invoices in site1.local (1bd3e0294d)
Traceback (most recent call last):
  File "/home/nescode/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.13.6', 'console_scripts', 'frappe')()
  File "/home/nescode/frappe-bench/apps/frappe/frappe/cli.py", line 39, in main
    ret = run(fn, args)
  File "/home/nescode/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/home/nescode/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/home/nescode/frappe-bench/apps/frappe/frappe/cli.py", line 431, in latest
    frappe.modules.patch_handler.run_all()
  File "/home/nescode/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/home/nescode/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 50, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/nescode/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 66, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/nescode/frappe-bench/apps/erpnext/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py", line 13, in execute
    % (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
  File "/home/nescode/frappe-bench/apps/frappe/frappe/database.py", line 121, in sql
    self._cursor.execute(query)
  File "/home/nescode/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/nescode/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 2")
Error: None
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/nescode/bench-repo/bench/cli.py", line 55, in cli
    bench()
  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/nescode/bench-repo/bench/cli.py", line 247, in update
    patch_sites()
  File "/home/nescode/bench-repo/bench/utils.py", line 116, in patch_sites
    exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites'))
  File "/home/nescode/bench-repo/bench/utils.py", line 72, in exec_cmd
    subprocess.check_call(cmd, cwd=cwd, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/home/nescode/frappe-bench/env/bin/frappe --latest all' returned non-zero exit status 1

And it says updating.

Sunil

I ran bench update and got a similar error. This is likely a database migration issue.

Its a v4 production fresh install.

I’ve been running V4 in production for sometime now, only when I ran the update did the error similar to yours pop-up.

how you resolved it?

I have an error like this too

Executing erpnext.patches.v4_2.delete_gl_entries_for_cancelled_invoices in site2.local (a46003081c)
Traceback (most recent call last):
File “/home/phil/frappe-bench/env/bin/frappe”, line 9, in
load_entry_point(‘frappe==4.12.1’, ‘console_scripts’, ‘frappe’)()
File “/home/phil/frappe-bench/apps/frappe/frappe/cli.py”, line 39, in main
ret = run(fn, args)
File “/home/phil/frappe-bench/apps/frappe/frappe/cli.py”, line 83, in run
out = globals().get(fn)(**args)
File “/home/phil/frappe-bench/apps/frappe/frappe/cli.py”, line 67, in new_fn
return fn(*args, **new_kwargs)
File “/home/phil/frappe-bench/apps/frappe/frappe/cli.py”, line 431, in latest
frappe.modules.patch_handler.run_all()
File “/home/phil/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 25, in run_all
if not run_single(patchmodule = patch):
File “/home/phil/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 50, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/phil/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 66, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/phil/frappe-bench/apps/erpnext/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py”, line 14, in execute
% (’, ‘.join([’%s’]*len(cancelled_invoices))), tuple(cancelled_invoices))
File “/home/phil/frappe-bench/apps/frappe/frappe/database.py”, line 121, in sql
self._cursor.execute(query)
File “/home/phil/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/phil/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘)’ at line 2”)
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/phil/bench-repo/bench/cli.py”, line 55, in cli
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/phil/bench-repo/bench/cli.py”, line 247, in update
patch_sites()
File “/home/phil/bench-repo/bench/utils.py”, line 116, in patch_sites
exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, ‘sites’))
File “/home/phil/bench-repo/bench/utils.py”, line 72, in exec_cmd
subprocess.check_call(cmd, cwd=cwd, shell=True)
File “/usr/lib/python2.7/subprocess.py”, line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘/home/phil/frappe-bench/env/bin/frappe --latest all’ returned non-zero exit status 1

I’ve found a temporary issue :

1- MAKE BACKUP OF FILES

2- Delete 2 files in /apps/erpnext/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py and .pyc

3- Remove the line (the last line for me) of delete_gl_entries_for_cancelled_invoices in /apps/erpnext/erpnext/patches.txt

4- Run “bench update”

Thx u @philinfo for solution. But error log refers something different than just deleting gl_entries. I think Erpnext development team should step-in and suggest better way around to get rid of such issue to make Erpnext v4.xx rock solid stable.

At least, “bench update” must not breaks system. I think time has when development team should priorities “ROBUSTNESS” before anything else.

Sunil

I faced similar error

update went smooth when I did the following.

$ bench switch-to-v4

and then

$ bench update

bench switch-to-v4 Error:
https://discuss.frappe.io/t/bench-switch-to-v4-error/5451

Yes I know, that is the reason I’ve wrote Temporary. That get my site online :slight_smile: while they fix the problem

Error is still there. Unable to fix it.