-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start genie but throw a Python error: "UnicodeEncodeError" #268
Comments
That's an odd one. What is the hostname of your machine? |
I gave my computer a Chinese name called "机械革命." So, should my machine's hostname be in English? |
I'm wasn't totally sure about this. I started out assuming that Unicode would be acceptable in hostnames, but when I tried to set your hostname (or other non-ASCII hostnames) with the hostname(1) or hostnamectl(1) commands, they both rejected it:
And then when I looked it up, it seems that Unicode isn't allowed:
So from that, it looks like only English (and a limited subset of English, at that) hostnames are allowed. There is a way to encode other character sets into hostnames for DNS purposes, Punycode, but while that translates 机械革命 into xn--ltrx94bc6a885i and back again, using the latter as a hostname in Linux appears on screen, etc., as xn--ltrx94bc6a885i; it seems to be only web browsers and such that translate it into the proper characters for display. I'll see what I can do to fix the Unicode error anyway, but I suspect there are probably more problems down the road trying to use a non-ASCII hostname, at least for now. Sorry. |
'机械革命' is the hostname of my Windows OS. Because Windows allows Chinese hostnames. So maybe WSL inherited its hostname. I will try to change the hostname to English, observe if there are any problems, and then give feedback again. I appreciate your efforts to fix the problem, and it would be great if Chinese hostnames were allowed in later versions! |
I have changed my hostname to English, and now everything seems normal. So the problem is indeed the Chinese hostname. Thanks for your help! If fixing this problem is too complicated, you could close the issue. But I still expect that if possible, |
I checked into the Windows side of this too ( https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/naming-conventions-for-computer-domain-site-ou#dns-host-names ), which apparently boils down to Windows supports Unicode hostnames, as does the Microsoft DNS server that ships with Windows Server, but they acknowledge that non-Microsoft implementations of DNS, etc., don't support Unicode and so they should be avoided if they're going to travel outside a pure-Microsoft system. Unfortunately, given that the underlying problem seems embedded into Linux (and Internet standards in general, per RFC952 / RFC 1123) I don't think it's something that can be fixed just in genie. I'd like to leave this open for a while, though, both so I can put better error-handling in genie, and so that I can raise this issue with the WSL team so that other people don't run into this same issue in future. |
On another note, you can configure a separate hostname for a WSL distro by adding some lines in the /etc/wsl.conf file:
...so that might offer an alternative which fixes the WSL hostname issue without needing you to change the Chinese hostname of the Windows machine. |
Better error-handling and warning message now added to genie. Now just waiting on the underlying WSL fix, so closing this in favor of microsoft/WSL#8386. |
Windows version (build number):
Windows 11 Dev Channel build 22616.1 (the latest one)
Linux distribution:
Ubuntu
Kernel version:
5.10.102.1-microsoft-standard-WSL2
Genie version:
genie 2.3
Describe the bug
When I use the command "genie -s" to start it, it throws a python error:
genie: WARNING: systemd default target is default.target; targets other than multi-user.target may not work
genie: WARNING: if you wish to use a different target, this warning can be disabled in the config file
genie: WARNING: if you experience problems, please change the target to multi-user.target
Traceback (most recent call last):
File "/home/{my_username}/anaconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/{my_username}/anaconda3/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/genie/genie/main.py", line 904, in
File "/usr/lib/genie/genie/main.py", line 887, in entrypoint
File "/usr/lib/genie/genie/main.py", line 590, in do_initialize
File "/usr/lib/genie/genie/main.py", line 229, in hostname_update
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
could not initialise bottle, exit code = 1
Confirm that you are running inside the bottle:
no-bottle
I confirm that I have read the ENTIRE supplied readme file and checked for relevant information on the repository wiki before raising this issue, and that if the solution to this issue is found in either location, it will be closed without further comment:
The text was updated successfully, but these errors were encountered: