Frappe error when running commands

I have a working ERPNext instance on an AWS EC2 instance on Ubuntu 18.04. I have tried to set it up with the s3_backup app. I have installed boto and filechunkio and I have run “bench get-app s3_backup GitHub - bailabs/s3_backup: Amazon S3 BackUp for Frappe and ERPNext”. After this, I have run “bench install-app s3_backup”, which resulted in the following error output:
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
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/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/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 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 353, in uninstall
for site in context.sites:
TypeError: ‘NoneType’ object is not iterable

I also tried running “bench clear-cache”, which gave the following:
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
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/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/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 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py”, line 45, in clear_cache
for site in context.sites:
TypeError: ‘NoneType’ object is not iterable

It seems that most bench commands seem to result in this “TypeError: ‘NoneType’ object is not iterable”. Is there something that I could have misconfigured with my bench/frappe/erpnext which could be causing this?

Your site seems to be broken, to help diagnose what’s amiss:

frappe@ubuntu1804lts:~/frappe-bench$ ls -al sites/
total 32
drwxrwxr-x 4 frappe frappe 4096 Apr 13 20:58 .
drwxrwxr-x 7 frappe frappe 4096 Feb  4 03:45 ..
-rw-rw-r-- 1 frappe frappe  843 Apr 13 20:58 a8f876536f
-rw-rw-r-- 1 frappe frappe   14 Feb  5 19:39 apps.txt
drwxrwxr-x 4 frappe frappe 4096 Apr 20 20:14 assets
-rw-rw-r-- 1 frappe frappe    0 Apr 20 20:14 .build
-rw-rw-r-- 1 frappe frappe  546 Apr  1 16:53 common_site_config.json
-rw-rw-r-- 1 frappe frappe   11 Feb  5 18:55 currentsite.txt
drwxrwxr-x 7 frappe frappe 4096 Apr  1 16:55 site1.local

frappe@ubuntu1804lts:~/frappe-bench$ cat sites/currentsite.txt 
site1.localfrappe@ubuntu1804lts:~/frappe-bench$

frappe@ubuntu1804lts:~/frappe-bench$ bench console
Apps in this namespace:
frappe, erpnext

In [1]: context?
Type:        _dict
String form: {'sites': ['site1.local'], 'force': False, 'verbose': False, 'profile': False}
Length:      4
File:        ~/frappe-bench/apps/frappe/frappe/__init__.py
Docstring:   dict like object that exposes keys as attributes

To reset your site with say bench use site1.local may help?

I ran bench use mysitename and it seems to have fixed the issue. bench console also gives similar output to your output.

Thank you for you assistance.