0

After updating my Arch Linux system yesterday, I started getting an error similar to this:

Failed to set locale. Fix your system.

This specific error comes from trying to run snapper. However, here is another related error:

bsdcpio: Failed to set default locale

perl gives a similar warning which I will paste below.

It is not limited to any specific application; it appears to be a system-wide issue.

I did not get these errors prior to yesterday's update. Furthermore, I do not get the errors in a virtual console. I only get them when inside X (KDE). For example I get the error above if I run a snapper ls command in konsole, but I do not get any error if I run the same snapper ls command in a virtual console.

My other Arch systems, which are nearly identical, do not have this issue.

My first attempts at troubleshooting were as follows.

  1. check /etc/locale.conf
  2. run locale-gen
  3. check output of locale
  4. see if snapper runs without an error

I see no errors in locale.conf but running local-gen does not resolve the issue.

Here is the relevant output:

# localectl list-locales
en_US.utf8

# grep -v "^#" /etc/locale.conf
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

# locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

# locale-gen
Generating locales...
en_US.UTF-8... done
Generation complete.

# locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

# locale -a
C
en_US.utf8
POSIX

Here's perl's warning:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LC_MEASUREMENT = "en_US.UTF-8",
        LC_PAPER = "en_US.UTF-8",
        LC_MONETARY = "en_US.UTF-8",
        LC_NAME = "en_US.UTF-8",
        LC_COLLATE = "en_US.UTF-8",
        LC_CTYPE = "en_US.UTF-8",
        LC_ADDRESS = "en_US.UTF-8",
        LC_NUMERIC = "en_US.UTF-8",
        LC_MESSAGES = "en_US.UTF-8",
        LC_TELEPHONE = "en_US.UTF-8",
        LC_IDENTIFICATION = "en_US.UTF-8",
        LC_TIME = "en_GB.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

The following line appears when I run locale inside Konsole (in X), but not when I run locale in a virtual console:

locale: Cannot set LC_ALL to default locale: No such file or directory

I can run the snapper ls command in a virtual console without errors.

As far as I know, Arch doesn't have a /etc/default/locale. That file is not present on any of my Arch machines.

Rebooting the system did not help.

  • @Fox Generating locale en_GB.UTF-8 did fix it. If you post an answer, I'll accept it. What I don't understand is where LC_TIME=en_GB.UTF-8 is being set because /etc/locale.conf lists LC_TIME="en_US.UTF-8" – MountainX for Monica Cellio Jan 19 '18 at 3:07
  • I found the cause. A user had set the time format to "United Kingdom-British English" in KDE's system settings. Unaware the user had made this change, when I ran the Arch update yesterday, I replaced /etc/locale.gen with the pacnew file and I only enabled en_US.UTF-8. Next time I won't skip the diff. – MountainX for Monica Cellio Jan 19 '18 at 3:19
3

One of your locale settings (namely, LC_TIME) is set to a locale that you have not generated (namely, en_GB.UTF-8). The error will go away if you enable that locale in /etc/locale.gen and regenerate the locales.

Since the setting differs from that set in /etc/locale.conf, you may have placed an override in one of your startup scripts. Since the error does not occur in a virtual console, I suspect .xinitrc or .xprofile. However, if you are using a full desktop environment, those often have their own settings, including locale settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.