Comment 1 for bug 2020064

Revision history for this message
Juanmi Taboada (juanmitaboada) wrote :

I think the client machine should address this bug. A hint to resolve it could be:
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=C.UTF-8

Landscape Client could also try to prevent future failures when detected by applying the solution proposed above:

@@ -3,6 +3,7 @@
 except ImportError:
     import urllib.parse as urlparse

+import subprocess
 import locale
 import logging
 import time
@@ -943,7 +944,12 @@
 def main(args):
     # Force UTF-8 encoding only for the reporter, thus allowing libapt-pkg to
     # return unmangled descriptions.
- locale.setlocale(locale.LC_CTYPE, ("C", "UTF-8"))
+ try:
+ locale.setlocale(locale.LC_CTYPE, ("C", "UTF-8"))
+ except locale.Error:
+ subprocess.run(["sudo", "locale-gen", "en_US.UTF-8"], check=True)
+ subprocess.run(["sudo", "update-locale", "LANG=C.UTF-8"], check=True)
+ raise

     if "FAKE_GLOBAL_PACKAGE_STORE" in os.environ:
         return run_task_handler(FakeGlobalReporter, args)

There is a PR with this proposed solution at:
https://github.com/CanonicalLtd/landscape-client/pull/161