ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Permission error on bench update


#1

Hello,

I’m on develop branch, and I recently tried to do a bench update. I’m getting the following permissions error traceback. Any tips?

**$ bench update**
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
Requirement already satisfied: olefile in ./env/lib/python2.7/site-packages (from Pillow)
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull  upstream develop
From https://github.com/frappe/frappe
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete
INFO:bench.app:pulling erpnext
INFO:bench.utils:git pull  upstream develop
From https://github.com/frappe/erpnext
 * branch            develop    -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete
Updating Python libraries...
INFO:bench.utils:./env/bin/pip install --upgrade pip
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
INFO:bench.utils:./env/bin/pip install -q -r /home/peter/bench-repo/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
Updating node packages...
INFO:bench.utils:yarn install
yarn install v0.27.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.49s.
Backing up sites...
Patching sites...
Migrating erp.theopen.institute
Executing erpnext.patches.v10_0.item_barcode_childtable_migrate in erp.theopen.institute (9ed8d899d738b1d3)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/peter/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/peter/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/peter/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/peter/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/peter/frappe-bench/apps/frappe/frappe/commands/site.py", line 222, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/peter/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/peter/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/peter/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/peter/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/peter/frappe-bench/apps/erpnext/erpnext/patches/v10_0/item_barcode_childtable_migrate.py", line 10, in execute
    items_barcode = frappe.get_list('Item', ['name', 'barcode'], { 'barcode': ('!=', '') })
  File "/home/peter/frappe-bench/apps/frappe/frappe/__init__.py", line 1150, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
  File "/home/peter/frappe-bench/apps/frappe/frappe/model/db_query.py", line 87, in execute
    result = self.build_and_run()
  File "/home/peter/frappe-bench/apps/frappe/frappe/model/db_query.py", line 99, in build_and_run
    args = self.prepare_args()
  File "/home/peter/frappe-bench/apps/frappe/frappe/model/db_query.py", line 118, in prepare_args
    self.build_conditions()
  File "/home/peter/frappe-bench/apps/frappe/frappe/model/db_query.py", line 283, in build_conditions
    match_conditions = self.build_match_conditions()
  File "/home/peter/frappe-bench/apps/frappe/frappe/model/db_query.py", line 404, in build_match_conditions
    frappe.throw(_("No permission to read {0}").format(self.doctype), frappe.PermissionError)
  File "/home/peter/frappe-bench/apps/frappe/frappe/__init__.py", line 323, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/peter/frappe-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
    _raise_exception()
  File "/home/peter/frappe-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
frappe.exceptions.PermissionError: No permission to read Item

#3

Here’s a stab in the dark…

In line 10 of the item_barcode_childtable_migrate.py file where you have:

items_barcode = frappe.get_list('Item', ['name', 'barcode'], { 'barcode': ('!=', '') })

change it to

items_barcode = frappe.get_all('Item', ['name', 'barcode'], { 'barcode': ('!=', '') })

Bench will complain if you run bench update so run bench migrate. If it works, please commit the change to a new branch and open a PR for it.