ERPNext Conference 2019* ERPNext.com Blog

No Longer able to setup Lets Encrypt on v11 (generates error)


#1

Ok,

I just installed a fresh v11 system on a KVM type VPS

Since I was installing v11 I changed the install.py to default to v11 so it would not install v12 and then I used the regular easy method to install a --production system.

I set my hostname properly and ran through the setup wizard on the first login as Administrator.

Next I logged out, closed the browser, opened a ssh session and did the following:
cd frappe-bench
bench config dns_multitenant on
bench setup add-domain --site site1.local erp.mynewsite.com
sudo bench setup lets-encrypt site1.local --custom-domain erp.mynewsite.com

At this point I got an error:

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/erp_jmi/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/erp_jmi/.bench/bench/commands/setup.py", line 22, in setup_nginx
    make_nginx_conf(bench_path=".", yes=yes)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 13, in make_nginx_conf
    sites = prepare_sites(config, bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 100, in prepare_sites
    sites_configs = get_sites_with_config(bench_path=bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 217, in get_sites_with_config
    if isinstance(domain, str) or isinstance(domain, unicode):
NameError: name 'unicode' is not defined

At this point the site went down. So, rebooted the server and the site was still down.
Now I realized that the script had not been able to setup nginx with the new setings so it could then be restarted.

I opened an fresh ssh session and did the following:

cd frappe-bench
bench setup nginx
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/erp_jmi/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/erp_jmi/.bench/bench/commands/setup.py", line 22, in setup_nginx
    make_nginx_conf(bench_path=".", yes=yes)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 13, in make_nginx_conf
    sites = prepare_sites(config, bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 100, in prepare_sites
    sites_configs = get_sites_with_config(bench_path=bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 217, in get_sites_with_config
    if isinstance(domain, str) or isinstance(domain, unicode):
NameError: name 'unicode' is not defined

Again the same error!!!

Then I noticed that it was trying to use python 3 to do the nginx setup.
I did not install the system with python 3, I did it using the python 2.7 because there are NO instructions yet on how to install with python 3!!!

Can anyone identify a way to get around this?

Is there a valid way to do an easy install with python3 yet? If so how?
( I would have no problem wiping the server and starting again if there is a way to do it with python3)

At this point I am stuck with a broken ERPNext install that I cannot access because I cannot tun the setup for nginx.

Please adivse.

BKM


Bench setup nginx - No longer works! (v11)
#2

Hi @bkm,

I think you should switch to python3

$ bench migrate-env python3

This fixed my issue.


#3

Hmm… I did that. The migration to python3 said it completed with success. I rebooted the server then executed the setup nginx command again:

p:~/frappe-bench$ bench setup nginx
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/erp_jmi/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/erp_jmi/.bench/bench/commands/setup.py", line 22, in setup_nginx
    make_nginx_conf(bench_path=".", yes=yes)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 13, in make_nginx_conf
    sites = prepare_sites(config, bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 100, in prepare_sites
    sites_configs = get_sites_with_config(bench_path=bench_path)
  File "/home/erp_jmi/.bench/bench/config/nginx.py", line 217, in get_sites_with_config
    if isinstance(domain, str) or isinstance(domain, unicode):
NameError: name 'unicode' is not defined

That didn’t help any. I am still getting the same error.

Evidently there is some other error going on with the ‘bench setup nginx’ error.
The last line of the error says something about the name ‘unicode’ is not defined. What does that mean?
Any other ideas?

BKM


#4

Found a patch solution in another thread. Not pretty, but it works.

It makes you wonder if the devs bother to check this stuff before they publish it. Anyway, here is the link to the patch that will let both the lets encrypt and the setup nginx commands work properly again:

Hope this helps someone else.

BKM