Locale setting

Mar 05, 2023 Last reply: 3 years ago 23 Replies

I've got 8 Pis running. 7 of them SSH or SCP to the other one at various times. One of them (pi5) is now running Bullseye, and seems to have the locale set to en_US.UTF8, whereas the other 7 are on older OS versions and have the locale set to en_GB.UTF-8.



When I try to SSH from pi5 to any of the others, I get :


-bash: warning setlocale: LC_ALL: cannot change locale (en_US.UTF-8)



I've tried using locale-gen to change the default on pi5 to the en_GB version, but it seems to hang. using raspi-config fails, generating a pile of error messages ending "No such file or directory"



Altering $HOME/.profile and adding :



LANG=en_GB.UTF-8



seems to work, to the extend that echo $LANG now gives me the right value, but the SSH still gives me the same error.



Running locale gives me :



locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_GB.UTF8



but all other entries are en_US.UTF-8



So what to try next ?



Adrian


It does take a *long* time to run, maybe you weren't patient enough.

I just tried it on my (only) Pi 4:-

root@pimedia:~# vi /etc/locale.gen root@pimedia:~# locale-gen Generating locales (this might take a while)... en_GB.UTF-8... done en_US.UTF-8... done Generation complete. root@pimedia:~#

It took a fairly long time, maybe 30 seconds or more.

using raspi-config fails, generating a

In message snipped-for-privacy@esprimo.zbmc.eu>, Chris Green snipped-for-privacy@isbd.net writes

Thanks. I know a Pi 3 is a bit slower than a Pi 4, but this was still running after ~10 minutes when I killed it. I'll try it again with the time command, and see what it comes up with. I doubt it makes any difference, but I was running it via sudo rather than from root.

<goes off to play on pi5>

OK, having had another look, what I'd run, that I ended up Crtl-Cing was locale-gen en_GB.UTF-8. Running what you did, it took 20 seconds, but didn't make any difference to the locale settings.

Adrian

If I had to guess, I would say this is due to missing locale files as both raspi-config and locale are complaining about "No such file or directory". I would check the folder where your locale definitions are stored (on my system /usr/lib/locale) for the en_GB.UTF-8 locale definition. If it isn't there, that could be your problem.

dpkg-reconfigure locales

If it took > 10 minutes, then something was wrong. I sometimes have to run localegen after a software update, because I prefer the "date" command to put the fields in a logical order "Sun 5 Mar 2023 21:33:49 GMT" rather than the bizarre UNIX default of (I think) "Sun 5 Mar

21:33:49 GMT 2023" (*); although I edit the file within the i18n tree structure, sometimes an update causes it to revert.

I think localegen on both my Pi3 and Pi4 takes less than a minute to run

- maybe quite a bit less.

(*) Who decided that it was a good idea to separate the year from the day and month, with the time and timezone in between? It makes no more sense for UK DD MMM YYYY format than it does for US MMM DD YYYY format. For countries that use YYYY-MMM-DD format, I wonder how "date" listed it

- maybe "Sun 2023 21:33:49 GMT 5 Mar" ;-)

In message <tu2vev$1edl5$ snipped-for-privacy@dont-email.me, Doc O'Leary <?. snipped-for-privacy@2023.impossiblystupid.com.invalid> writes

Thanks, but no joy there. perl: warning: setting locale failed. perl: warning: Please check that your locale setting: LANGUAGE = "en_US.UTF-8", LC_ALL = "en_US.UTF-8", LANG = = "en_US.UTF-8" are supported and installed on your system. perl: warning: falling back to a default locale ("en_GB.UTF-8") locale: cannot set LC_CTYPE to default locale: No such file or directory locale: cannot set LC_MESSAGES to default locale: No such file or directory locale: cannot set LC_ALL to default locale: No such file or directory /usr/bin/locale: Cannot set LC_TYPES to default locale: No such file or directory /usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory Generating locales (this might take a while)... en-GB.UTF-8... done Generation complete.

*** update-locale: Error: invalid locale settings: LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_GB.UTF-8

Adrian

In message snipped-for-privacy@gmail.com, jeshgrca snipped-for-privacy@gmail.com writes

Thanks. You might be onto something there.

ls -l /usr/lib/locale total 2900 drwxr-xr-x 3 root root 4096 Mar 1 15:49 C.UTF-8

-rw-r--r-- 1 root root 3041504 Mar 5 19:01 locale-archive

And that is it. So where have the others gone ?

Adrian

Looks like they might be in 'locale-archive', possibly compressed. If so, you should just be able to decompress them, copy them out of 'locale-archive', and reconfigure your locale settings.

Thanks.

It may well be a compressed archive, but I've been unable to work out what type :

file locale-archive locale-archive: locale archive 11 strings

tar, unzip and ar don't know what to do with it.

Strings shows a whole load of stuff, which could well be right for en_GB, but how to get the system to use it is a different matter.

Adrian

Having done a bit of research, locale-archive appears to be some sort of special file. According to 'man localedef' you can list the locales in said special file and add new locales to it if necessary.

In message snipped-for-privacy@gmail.com, jeshgrca snipped-for-privacy@gmail.com writes

Thanks

$ localedef --list-archive en_GB.UTF8

So it looks as though I've got the right one available, but how do I get it to use it ?

Adrian

The year being tacked onto the end looks like an afterthought. "Oh, I guess some people do need the year after all..."

I've converted all my stuff to ISO 8601, and preach its virtues at every opportunity (like now :-).

Surely you're supposed to use raspi-config for this.

sudo raspi-config

In message snipped-for-privacy@mid.individual.net>, Brian Gregory snipped-for-privacy@email.invalid writes

I've tried that. I select the locale that I want, and then "OK". It thinks about it for a while, and then comes up with the following in a grey box :

There was an error running option L1 Locale

<Ok>

That was my first option, when that failed, I started exploring the other options, which whilst failing, at least give some more helpful error messages.

Adrian

I would say that probably means your Raspberry Pi OS installation has been customised in some way or is corrupt.

In message snipped-for-privacy@mid.individual.net>, Brian Gregory snipped-for-privacy@email.invalid writes

Could be.

I downloaded the Bullseye distro, and then copied (is that the right word) it onto a SD card. So far as I can tell, everything else works OK.

Adrian

I certainly use ISO 8601 (YYYY-MM-DD) when including a date in a filename, so the files sort by name into date order.

And in newsgroup postings which might be seen outside the UK, I tend to write dates as 06 Mar 2023 rather than 06/03/2023 to avoid any confusion with June 3 2023 in US format: 6 Mar 2023 is understandable "everywhere" (even in France and Germany which abbreviate Mars or Marz to Mar) even if American might write it Mar 6 2023.

As an American myself, I don't really have a preference for the order of terms, whether it be MM/DD/YYYY or YYYY-MM-DD or whatever else. I just wish we could all agree an a standard so Europeans aren't confused about not seeing 9/11 memes on November 9 anymore.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required