How I upgraded from v13 to v14 and Ubuntu 20.04 LTS to 22.04 LTS

First, I made sure my last nightly backup of the VM was successful. Then I backed up the site with bench --site *sitename* backup --with-files and copied the backups off-host. Then I made another snapshot of the VM. Being OCD with backups is helpful with this kind of upgrade!

Next, I upgraded frappe-bench to the latest: pip3 install frappe-bench --upgrade

At this point, I followed this guide to upgrade to Python 3.10 and pip to the latest version.

Next, I ran bench restart and tested the site in the browser to make sure it was still working. Took another VM snapshot.

Next, I upgraded from Ubuntu 20.04 LTS to 22.04 LTS with sudo do-release-upgrade -d and after the reboot, browser-tested to make sure the site was still working. So far so good! Took another VM snapshot.

Next up is to upgrade node from v14 to v16 via nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash
exit shell and login again
nvm install 16 --reinstall-packages-from=current

EDIT: Here, I found it necessary to upgrade frappe-bench again: pip3 install frappe-bench --upgrade

Then restart bench: bench restart and browser test again. Took another VM snapshot.

Switched to branch 14, but upgrade was not successful and ended with errors: bench switch-to-branch version-14 --upgrade

Installed app hrms:
bench get-app hrms
bench --site *sitename* install-app hrms

Tried again, but had more problems and errors. Installed payments app:
bench get-app payments
bench --site *sitename* install-app payments

Ran bench migrate and bench update --reset due to issues with untracked files in git.

Ran bench restart for good measure and tested the site- working!

EDIT: do not remove the payments app here at this point as I originally posted!

Browser tested again: Success! As always, YMMV. And my errors and workarounds with regard to installing the apps after the bench switch-to-branch command may have been avoidable by adding resolve-deps as noted in that post. Good luck and don’t forget to back up a lot!

14 Likes

Hi,
When I migrate ERP using ‘bench switch-to-branch version-14 --upgrade’ i have sql query error for table tabDocType State. When I checked sql schema I notice that table ‘tabDocType State’ is missing.

To fix this error you need to execute bench migrate, and after that one more time bench switch-to-branch version-14 --upgrade

1 Like

Yes, I’ve been doing some more experimenting with the upgrade. I think I found a better way to do this which results in fewer errors (replace ‘bench switch-to-branch version-14 --upgrade’ and the following commands with these) :

~/frappe-bench$ bench get-app --branch version-14 frappe
~/frappe-bench$ bench get-app payments
~/frappe-bench$ bench get-app --branch version-14 erpnext
~/frappe-bench$ bench get-app hrms
~/frappe-bench$ bench --site sitename install-app hrms
~/frappe-bench$ bench migrate

I was using ERPNext v13.9 (Ubuntu 18.04) and was able to upgrade to ERPNext v13.37 (Ubuntu 20.04) and Python3.8. But to upgrade to v14 caused me problems. After upgrade to Python3.10, I tried to use “bench get-app” with any app and got errors like this:

......
Could not import runpy module
ModuleNotFoundError: No module named 'runpy'
ERROR:
Traceback (most recent call last):
  File "/home/frappe/.local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/commands/make.py", line 159, in get_app
    get_app(
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/app.py", line 432, in get_app
    app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/app.py", line 230, in install
    install_app(
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/app.py", line 561, in install_app
    bench.run(
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/bench.py", line 47, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd)
  File "/home/frappe/.local/lib/python3.10/site-packages/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError
...

Do you have any solution? Thanks

Did you upgrade pip after upgrading python as in the linked document? How about the pip3 upgrade of frappe-bench before that?

I’d recommend rolling back your installation to a pre-upgrade state and trying again following the above sequence and browser-testing after each step to isolate exactly where the problem is. You should have a working server after nearly every step- after upgrading python and pip, after upgrading frappe-bench, after upgrading Ubuntu, and again at the end.

Dear @trustedcomputer
I have done what you instructed step-by-step and something to consider:

  1. Upgrade to Python3.10: no problem until
    env/bin/pip install -e apps/frappe -e apps/erpnext

I can see the login page but when login using username and password. It is always “verifying” and not login

  1. Then I tried
    bench update --reset

It got error as follow:

Installing frappe
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: ‘/home/frappe/frappe-bench/env/lib/python3.10/site-packages/editable.frappe-13.37.0.pth’
Check the permissions.

ERROR:
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 8, in
sys.exit(cli())
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 127, in cli
bench_command()
File “/usr/lib/python3/dist-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/usr/lib/python3/dist-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/usr/lib/python3/dist-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/lib/python3/dist-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/lib/python3/dist-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/commands/update.py”, line 59, in update
update(
File “/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py”, line 425, in update
bench.setup.requirements()
File “/usr/local/lib/python3.10/dist-packages/bench/utils/render.py”, line 105, in wrapper_fn
return fn(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/bench.py”, line 441, in requirements
app = App(path_to_app, bench=self.bench, to_clone=False).install(
File “/usr/local/lib/python3.10/dist-packages/bench/utils/render.py”, line 126, in wrapper_fn
return fn(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/app.py”, line 230, in install
install_app(
File “/usr/local/lib/python3.10/dist-packages/bench/app.py”, line 561, in install_app
bench.run(
File “/usr/local/lib/python3.10/dist-packages/bench/bench.py”, line 47, in run
return exec_cmd(cmd, cwd=cwd or self.cwd)
File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 155, in exec_cmd
raise CommandFailedError
bench.exceptions.CommandFailedError

The login page is showing: “The system is being updated. Please refresh again after a few moments.”

  1. I then tried
    bench update --patch

It works and the login page appears as normal but again, cannot login due to “verifying”

It seems some kind of directory ownership problem?

This worked great for me. Needed to install the payments app to get mine to upgrade

another reference to upgrading ubuntu 20 to 22
https://www.techrepublic.com/article/how-to-upgrade-ubuntu-server-from-20-04-to-22-04/

After installing HRMS, is it just me or did you all get an error with the designation doctype being non-existent?

I am receiving the error in thread below:

Hello friend,
please restore old database backup in erpnext 13. and follow bellow instructions

ERPNext upgrade from Version 13 to Version 14 - Ubuntu. my problems was resolved using this link.

Thank you.

Hello friend,
please restore old database backup in erpnext 13. and follow bellow instructions

ERPNext upgrade from Version 13 to Version 14 - Ubuntu. my problems was resolved using this link.