Failed To Update 7.0 To 9.1

Hi,

I bench updated but getting the below error. My site show Sorry! We will be back soon. in browser.

Previous ver
ERPNext v7.0.33
Frappe v7.0.29

Current ver
erpnext 9.1.4
frappe 9.1.6

 root@server01:/home/frappe/frappe-bench# bench update
    INFO:bench.utils:updating bench
    INFO:bench.utils:git pull
    Already up-to-date.
    remote: Counting objects: 7, done.
    remote: Total 7 (delta 6), reused 7 (delta 6), pack-reused 0
    Unpacking objects: 100% (7/7), done.
    From https://github.com/frappe/frappe
       bc396d5..beeaa3f  hotfix     -> upstream/hotfix
    INFO:bench.utils:./env/bin/pip install Pillow
    Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
    INFO:bench.app:pulling frappe
    INFO:bench.utils:git pull  upstream master
    From https://github.com/frappe/frappe
     * branch            master     -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name "*.pyc" -delete
    INFO:bench.app:pulling erpnext
    INFO:bench.utils:git pull  upstream master
    From https://github.com/frappe/erpnext
     * branch            master     -> 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/frappe/.bench/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
    Updating node libraries...
    INFO:bench.utils:npm install
    npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
    npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.2
    npm WARN frappe@ No description
    Backing up sites...
    Patching sites...
    Migrating site1.local
    Executing finally:erpnext.patches.v7_0.update_timesheet_communications in site1.local (1bd3e0294da19198)
    Success
    Executing erpnext.patches.v8_0.disable_instructor_role in site1.local (1bd3e0294da19198)
    Traceback (most recent call last):
      File "/usr/lib/python2.7/runpy.py", line 162, 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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
        main()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
        click.Group(commands=commands)(prog_name='bench')
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
        return self.main(*args, **kwargs)
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
        rv = self.invoke(ctx)
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
        return callback(*args, **kwargs)
      File "/home/frappe/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/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
        ret = f(frappe._dict(ctx.obj), *args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 217, in migrate
        migrate(context.verbose, rebuild_website=rebuild_website)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 31, in migrate
        frappe.modules.patch_handler.run_all()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
        if not run_single(patchmodule = patch):
      File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
        return execute_patch(patchmodule, method, methodargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
        frappe.get_attr(patchmodule.split()[0] + ".execute")()
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v8_0/disable_instructor_role.py", line 15, in execute
        role = frappe.get_doc("Role", "Instructor")
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 622, in get_doc
        return frappe.model.document.get_doc(*args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 68, in get_doc
        return controller(*args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 103, in __init__
        self.load_from_db()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 140, in load_from_db
        frappe.throw(_("{0} {1} not found").format(_(self.doctype), self.name), frappe.DoesNotExistError)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 319, in throw
        msgprint(msg, raise_exception=exc, title=title, indicator='red')
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
        _raise_exception()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
        raise raise_exception(encode(msg))
    frappe.exceptions.DoesNotExistError: Role Instructor not found
    root@server01:/home/frappe/frappe-bench#

Any help would be appreciated.

While it won’t help your specific issue, I have a similar issue and I think they are linked

My thinking here is the software over time has added a collection of “features” that are exhibited in the database structure itself and the code page is expecting these changes to reside in the database to properly run.

I wonder if there is a need to change the order of updates to migrate the database first (after backup set of course) and then run all the code against the upgraded database. That way all the functions that are expecting a certain database structure will work ok.

Not sure if this is the right approach, just a hunch I have right now.

When getting the below error (the error i mentioned before),

Error
frappe.exceptions.DoesNotExistError: Role Instructor not found

Did to solve
sudo bench --site site1.local mysql

insert into tabRole (name, creation, modified, modified_by, owner, docstatus, parent, parentfield, parenttype, idx, two_factor_auth, _liked_by, desk_access, _comments, _assign, restrict_to_domain, disabled, role_name, _user_tags) values('Instructor', '2017-10-15 23:46:43.813797', '2017-10-16 03:54:04.228414', 'Administrator', 'Administrator', 0, NULL, NULL, NULL, 0, 0, NULL, 1, NULL, NULL, NULL, 1, 'Instructor', NULL);

Then i ran into this error,

Error
AttributeError: 'DocType' object has no attribute 'restrict_to_domain'

Did to solve
as @James_Robertson suggested in link https://discuss.frappe.io/t/v8-to-v9-upgrade-error-domianification/29228

Now I’m getting the error as below that i cannot solve.

Error
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/loaders.py”, line 399, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: templates/includes/formats/common_format

This has stopped me. The mentioned location templates/includes/formats/ and the file common_format does not exist on the current installation nor does it exist on a new installation i brought up to compare.

Any leads from the community? This would be highly appreciated.

1 Like

Similar issue like yours:

I solved it by doing the following.

In apps/erpnext/
sudo git status
sudo git add --all

In apps/frappe/
sudo git status
sudo git add --all

In frappe/frappe-bench
sudo bench update --reset

Thank you @James_Robertson & @magic-overflow

2 Likes

@eitadmin Hope it may help