Bench switch-to-branch version-13-beta FAIL "NameError: name 'utils' is not defined"

Attempting to switch to branch “version-13-beta” from “version-12” fails with error message “NameError: name ‘utils’ is not defined”. Attempting switch-to-branch “develop” fails in the same way.

Fwiw the server started with a clean install of Ubuntu 20.04 LTS and ERPNext was installed using install.py (Easy install setup guide for erpnext installation on Ubuntu 20.04 LTS. With some modification of course ).

Is there a simple workaround for this?

Thanks,
Dale

frappe@starlord:~/frappe-bench$ bench switch-to-branch version-13-beta frappe erpnext --upgrade
LOG: Fetching upstream unshallow for frappe
$ git remote set-branches upstream  '*'
$ git fetch --all --unshallow
Fetching upstream
remote: Enumerating objects: 47241, done.
remote: Counting objects: 100% (40356/40356), done.
remote: Compressing objects: 100% (11777/11777), done.
remote: Total 38745 (delta 29630), reused 35598 (delta 26652), pack-reused 0
Receiving objects: 100% (38745/38745), 14.08 MiB | 5.21 MiB/s, done.
Resolving deltas: 100% (29630/29630), completed with 1083 local objects.
From https://github.com/frappe/frappe
 * [new branch]          SaiFi0102-patch-1                                  -> upstream/SaiFi0102-patch-1
 * [new branch]          assignment_rule                                    -> upstream/assignment_rule
... <snip>
Switching for frappe
$ git checkout version-13-beta
Updating files: 100% (907/907), done.
Branch 'version-13-beta' set up to track remote branch 'version-13-beta' from 'upstream'.
Switched to a new branch 'version-13-beta'
LOG: Fetching upstream unshallow for erpnext
$ git remote set-branches upstream  '*'
$ git fetch --all --unshallow
Fetching upstream
remote: Enumerating objects: 46956, done.
remote: Counting objects: 100% (35862/35862), done.
remote: Compressing objects: 100% (11559/11559), done.
remote: Total 33465 (delta 25512), reused 28869 (delta 21281), pack-reused 0
Receiving objects: 100% (33465/33465), 34.54 MiB | 5.89 MiB/s, done.
Resolving deltas: 100% (25512/25512), completed with 1659 local objects.
From https://github.com/frappe/erpnext
 * [new branch]            delivery_note                          -> upstream/delivery_note
 * [new branch]            dependabot/npm_and_yarn/lodash-4.17.19 -> upstream/dependabot/npm_and_yarn/lodash-4.17.19
... <snip>
Switching for erpnext
$ git checkout version-13-beta
Updating files: 100% (1725/1725), done.
Branch 'version-13-beta' set up to track remote branch 'version-13-beta' from 'upstream'.
Switched to a new branch 'version-13-beta'
SUCCESS: Successfully switched branches for: frappe, erpnext
Please run `bench update --patch` to be safe from any differences in database schema
Updating Python libraries...
$ ./env/bin/pip install -q -U pip
INFO:bench.app:installing frappe
$ ./env/bin/pip install -q -U -e ./apps/frappe
INFO:bench.app:installing erpnext
$ ./env/bin/pip install -q -U -e ./apps/erpnext
Updating node packages...
$ yarn install
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > bootstrap@4.4.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.4.1" has unmet peer dependency "popper.js@^1.16.0".
[4/4] Building fresh packages...
$ yarn run snyk-protect
yarn run v1.22.4
$ snyk protect
Successfully applied Snyk patches

Done in 54.68s.
Done in 1055.49s.
$ yarn install
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ yarn run snyk-protect
yarn run v1.22.4
$ snyk protect
Successfully applied Snyk patches

Done in 7.68s.
Done in 114.63s.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/.bench/bench/cli.py", line 41, 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/.bench/bench/commands/update.py", line 43, in switch_to_branch
    switch_to_branch(branch=branch, apps=list(apps), upgrade=upgrade)
  File "/home/frappe/.bench/bench/app.py", line 417, in switch_to_branch
    switch_branch(branch, apps=apps, bench_path=bench_path, upgrade=upgrade)
  File "/home/frappe/.bench/bench/app.py", line 409, in switch_branch
    reload_module(utils)
NameError: name 'utils' is not defined
frappe@starlord:~/frappe-bench$
1 Like

@Dale_Scott

Check your /home/frappe/.bench/bench/app.py file

OR

/home/your-erpnext-user-account/.bench/bench/app.py file

line 409, in switch_branch reload_module(utils)

Should be reload_module(bench.utils)

Correct this manually and then try to update again.

3 Likes

@Nikunj_Patel

Thanks for advice, the switch-to-branch now completes without errors, but the desk isn’t rendered after logging into ERPNext (just a blue “E” in middle of window). There was a message related to driver.js at the end of the bench update, could this be the cause?

Also early in the bench update there was a warning to run “bench update --patch”, which I did and it completed without error. Was this ok?

Thanks,
Dale

frappe@starlord:~/frappe-bench$ bench switch-to-branch version-13-beta frappe erpnext --upgrade
... <snip>
✔ Built js/data_import_tools.min.js
✔ Built js/report.min.js
UNRESOLVED_IMPORT : 'driver.js' is imported by frappe/public/js/frappe/ui/driver.js, but could not be resolved – treating it as an external dependency
Cannot find some dependencies. You may have to run "bench setup requirements" to install them.

MISSING_GLOBAL_NAME : No name was provided for external module 'driver.js' in output.globals – guessing 'Driver'
✔ Built css/frappe-web-b4.css
✔ Built js/desk.min.js
✨  Done in 857.782s

Building erpnext assets...

✔ Built js/erpnext-web.min.js
✔ Built js/item-dashboard.min.js
✔ Built css/erpnext.css
✔ Built css/marketplace.css
✔ Built js/erpnext.min.js
✔ Built css/erpnext-web.css
✔ Built js/marketplace.min.js
✨  Done in 156.424s
Done in 1026.14s.
--------------------------------------------------------------------------------Your bench was upgraded to version 13
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:

Site site1.local assigned port: 80
As you have setup your bench for production, you will have to reload configuration for nginx and supervisor. To complete the migration, please run the following commands
sudo service nginx restart
sudo supervisorctl reload
frappe@starlord:~/frappe-bench$

I’m facing the same exact issue!

I have a version-13-beta on development mode in my local machine working properly

but the clean install show a blank desktop

---- Update ----

@Dale_Scott

Check this, is the solution:
https://github.com/frappe/erpnext/issues/22084#issuecomment-637951052

I have just tested and works!

2 Likes

I ran “bench setup requirements” and “bench build,” and the desk now appears correctly.

@JeansReal Thank you for your suggestion but I did not upgrade node as I did not have any warnings or errors related to node.

@Nikunj_Patel Looking back at my first post, I see warnings about jquery and popper versions. Is this something to be concerned about?

3 Likes

@Dale_Scott

No jquery and popper versions should not bother you… ignore the warning and enjoy the Version 13.

2 Likes

Also, work for me…
Thank you…