Bench not working after attempt to upgrade to V13

Attempted to upgrade erpnext to V13. When I try to start bench, I am getting error:

$ bench update --patch
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 7, in
from bench.cli import cli
ModuleNotFoundError: No module named ‘bench’
$

Not sure what to do now? Cannot get bench to start

which subdirectory are you executing the bench update?

/home/frappe/frappe-bench

I see from the error it looks for bench in the linux’s bin subdirectory. Of course bench is not there. This means you are executing bench in the wrong subdirectory.

how do i set the folder for bench execution?

cd to your frappe-bench directory

I am in the folder /home/frappe/frappe-bench which is where the bench was installed before the failed upgrade to v13

How did you do the upgrade?

I ran these commands:

bench switch-to-branch version-13 frappe erpnext --upgrade
bench setup requirements
bench update --patch

when I did the upgrade, I remember seeing a warning about setting the path to .env so I exported the path in .bashrc. I’ll try to look this up later after I do my coding task for the night.

is above command executed succesfully ?

i tried this command outside bench

frappe@vmi417656 : /home $ bench switch-to-branch version-13 frappe erpnext --upgrade

WARN: Command not being executed in bench directory

ERROR: frappe does not exist!

ERROR: erpnext does not exist!

Are you confirmed the path is “/home/frappe/frappe-bench”

run ls and let me know what did you get?

image

i have since reinstalled bench, ran the switch-to-branch v13 command and received this message:

SUCCESS: Successfully switched branches for: frappe, erpnext

here is ls:
$ pwd
/home/frappe/frappe-bench
$ ls
apps bench-repo frappe-bench node_modules package.json Procfile
archived_envs config logs npm-debug.log patches.txt sites
$

now when running bench update --patch, i get this:

$ bench update --patch
Backing up sites…
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘frappe-bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 41, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/update.py”, line 25, in update
update(pull=pull, patch=patch, build=build, requirements=requirements, restart_supervisor=restart_supervisor, restart_systemd=restart_systemd, backup=not no_backup, force=force, reset=reset)
File “/home/frappe/.bench/bench/utils.py”, line 193, in update
backup_all_sites(bench_path=bench_path)
File “/home/frappe/.bench/bench/utils.py”, line 656, in backup_all_sites
backup_site(site, bench_path=bench_path)
File “/home/frappe/.bench/bench/utils.py”, line 651, in backup_site
run_frappe_cmd(‘–site’, site, ‘backup’, bench_path=bench_path)
File “/home/frappe/.bench/bench/utils.py”, line 769, in run_frappe_cmd
cwd=sites_dir, stdout=stdout, stderr=stderr)
File “/usr/lib/python2.7/subprocess.py”, line 394, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$

You need to upgrate python as well as bench.

sudo -H pip3 install --upgrade pip
bench migrate-env python3

getting this error on the migrate-env command:

$ bench migrate-env python3
DEBUG:bench.utils:Clearing Redis Cache…
$ /usr/bin/redis-cli -p 13000 FLUSHALL
OK
DEBUG:bench.utils:Clearing Redis DataBase…
$ /usr/bin/redis-cli -p 13000 FLUSHDB
OK
DEBUG:bench.utils:Backing up Virtual Environment
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘frappe-bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 41, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/utils.py”, line 182, in migrate_env
migrate_env(python=python, backup=backup)
File “/home/frappe/.bench/bench/utils.py”, line 1085, in migrate_env
os.rename(source, dest)
OSError: [Errno 2] No such file or directory
$