locale.Error: unsupported locale setting
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Landscape Client |
Fix Released
|
Undecided
|
Unassigned | ||
landscape-client (Ubuntu) |
In Progress
|
Undecided
|
Mitch Burton | ||
Focal |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
* When the C.UTF-8 locales is not installed, landscape-client's package
reporter service fails to start:
Traceback (most recent call last):
File "/usr/bin/
main(
File "/usr/lib/
locale.
File "/usr/lib/
return _setlocale(
locale.Error: unsupported locale setting
* This prevents landscape-client from reporting packages, preventing
all subsequent package activities.
[ Test Plan ]
* Edit /etc/default/locale to contain LANG=en_GB.UTF-8
* Run `sudo dpkg-reconfigure locales` and select only en_GB.UTF-8 and select
en_GB.UTF-8 as default locale
* ensure en_GB.UTF-8 is the _only_ selected locale, unselect other locales, en_US.UTF-8 in particular.
* sudo apt install landscape-client
* Attempt to start package-reporter:
sudo landscape-
Package Reporter should start without any exceptions. There will be no output
and the process will not exit unless killed.
* Register landscape-client with landscape server and wait for the package
reporter log to appear at /var/log/
should not contain any errors.
* Test again using a non-UTF-8 locale setting instead of en_GB.UTF-8
[ Where problems could occur ]
* As this is a reversion of a previous fix for a bug regarding locales, that
issue might re-occur with non-UTF-8 locales. A comment in LP: #1827857 claims
this has been fixed in python-apt, though.
* Packages with control file fields containing non-ASCII characters may be
reported incorrectly. The Debian Policy Manual says that package names cannot
contain these but other fields might,
[ Other Info ]
<ORIGINAL BUG REPORT FOLLOWS>
OS: Ubuntu 20.04.6 LTS
Landscape client: 23.02-0ubuntu1
Due to missing locale, the landscape client couldn't report the list of installed packages to the landscape server (SAAS).
2023-05-10 17:23:10,675 WARNING [MainThread] Package reporter output:
b'Traceback (most recent call last):
File "/usr/bin/
main(
File "/usr/lib/
locale.
File "/usr/lib/
return _setlocale(
locale.Error: unsupported locale setting
'
As a result, the server kept reporting available updates for the machine and when the update was triggered it failed with the following error reported in the task activity.
"Package data has changed. Please retry the operation."
For example on the affected client machine the "apt list --installed | grep dnsmasq-base" gives the output
"dnsmasq-
However, landscape server keeps reporting that update (2.80-1.1ubuntu1.7) is available.
Related branches
- Ubuntu Sponsors: Pending requested
- git-ubuntu import: Pending requested
-
Diff: 139 lines (+117/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/0002-fix-locale-error.patch (+108/-0)
debian/patches/series (+1/-0)
- Simon Quigley (community): Approve
- git-ubuntu import: Pending requested
-
Diff: 132 lines (+111/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/0002-fix-locale-error.patch (+102/-0)
debian/patches/series (+1/-0)
Changed in landscape-client: | |
status: | New → Confirmed |
Changed in landscape-client (Ubuntu): | |
status: | New → In Progress |
assignee: | nobody → Mitch Burton (mitchburton) |
description: | updated |
Changed in landscape-client: | |
status: | Confirmed → Fix Released |
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 setlocale( locale. LC_CTYPE, ("C", "UTF-8")) setlocale( locale. LC_CTYPE, ("C", "UTF-8")) run(["sudo" , "locale-gen", "en_US.UTF-8"], check=True) run(["sudo" , "update-locale", "LANG=C.UTF-8"], check=True)
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.
+ try:
+ locale.
+ except locale.Error:
+ subprocess.
+ subprocess.
+ raise
if "FAKE_GLOBAL_ PACKAGE_ STORE" in os.environ: handler( FakeGlobalRepor ter, args)
return run_task_
There is a PR with this proposed solution at: /github. com/CanonicalLt d/landscape- client/ pull/161
https:/