You are not logged in.

#1 2023-10-06 08:44:42

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

[SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

I'm using an Arch Linux environment where I'm testing the usage of "pacstrap". When I run:

sudo pacstrap /mnt base

after the installation of packages, I get as output:

<SNIP>
:: Running post-transaction hooks...
( 1/12) Creating system user accounts...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
( 2/12) Updating journal message catalog...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
( 3/12) Reloading system manager configuration...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Skipped: Running in chroot.
( 4/12) Updating udev hardware database...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
( 5/12) Applying kernel sysctl settings...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Skipped: Running in chroot.
( 6/12) Creating temporary files...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
( 7/12) Reloading device manager configuration...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Skipped: Running in chroot.
( 8/12) Arming ConditionNeedsUpdate...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
( 9/12) Rebuilding certificate stores...
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
(10/12) Reloading system bus configuration...
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Skipped: Running in chroot.
(11/12) Add Athena specific config
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

I guess it is considering "LC_ALL" variable from the host and not the one from the mount point (?).

The "/etc/locale.conf" of the Arch host is:

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8

While "/etc/locale.gen" of the host contains:

en_US.UTF-8 UTF-8

"locale -a" output from the host:

C
C.utf8
en_US.utf8
POSIX

How can I solve the warning "/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)" in the mount point before running "pacstrap /mnt base"?

If I run "sudo locale-gen" on the Arch host, it does not solve the warning. I can "arch-chroot" inside "/mnt" and try to run "locale-gen" but if I do that BEFORE running "pacstrap /mnt base" command, I don't have "locale-gen" command available.

Last edited by D3vil0p3r (2023-10-06 15:06:34)

Offline

#2 2023-10-06 10:23:12

loqs
Member
Registered: 2014-03-06
Posts: 18,130

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Why is LC_ALL set in /etc/locale.conf?
Edit:
Also LANGUAGE is wrong see Locale#LANGUAGE:_fallback_locales.

Last edited by loqs (2023-10-06 10:27:41)

Offline

#3 2023-10-06 10:31:14

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

loqs wrote:

Why is LC_ALL set in /etc/locale.conf?

Because if I don't set it there, I get that warning message as:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

I know that ArchWiki says:

LC_ALL is the only LC_* variable which cannot be set in locale.conf files

ref: https://wiki.archlinux.org/title/locale … leshooting

So it means that I should not set "LC_ALL" anywhere in a production environment? If so, how can I avoid that warning with (unset)?

Offline

#4 2023-10-06 10:54:47

loqs
Member
Registered: 2014-03-06
Posts: 18,130

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

What if you change /etc/locale.conf to:

LANG=en_US.utf8

Offline

#5 2023-10-06 12:12:51

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

If I set only that variable in /etc/locale.conf and keeping only "en_US.UTF-8 UTF-8" in /etc/locale.gen, in the mount point I get:

(11/12) Warn about old perl modules
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Last edited by D3vil0p3r (2023-10-06 12:14:08)

Offline

#6 2023-10-06 12:23:27

loqs
Member
Registered: 2014-03-06
Posts: 18,130

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

If you replace en_US.UTF-8 UTF-8 with en_US.utf8 is there any chance?

Offline

#7 2023-10-06 12:27:03

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,182

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

What does `locale` give?

Offline

#8 2023-10-06 12:29:48

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

loqs wrote:

If you replace en_US.UTF-8 UTF-8 with en_US.utf8 is there any chance?

So, you mean to remove the charset part of "en_US.UTF-8 UTF-8" (that is the last UTF-8) and remove the dash in "en_US.UTF-8" in /etc/locale.gen?

If I try to do this in the host and run"sudo locale-gen", I get an error:

Generating locales...
error: Bad entry 'en_US.UTF-8 '
Generation complete.

if I keep the dash or:

Generating locales...
error: Bad entry 'en_US.UTF8 '
Generation complete.

if I don't keep it.

Offline

#9 2023-10-06 12:32:38

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,182

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

They meant in locale.conf, not locale.gen.

Offline

#10 2023-10-06 12:34:26

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Scimmia wrote:

They meant in locale.conf, not locale.gen.

locale.conf was already as:

LANG=en_US.UTF-8
Scimmia wrote:

What does `locale` give?

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_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=

Last edited by D3vil0p3r (2023-10-06 12:35:53)

Offline

#11 2023-10-06 12:40:06

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

I can solve those errors/warnings by entering the mount point by "arch-chroot" and running "locale-gen". But "locale-gen" should be a binary obtained from "glibc" that is inside "base" metapackage, but if I install "base" by pacstrap, it generates the output on the first post and I cannot run "locale-gen" before "pacstrap /mnt base" because at that time "locale-gen" command does not exist. I hope the scenario is clear.

Last edited by D3vil0p3r (2023-10-06 12:40:54)

Offline

#12 2023-10-06 12:45:06

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,182

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Are you giving us some output from outside the chroot and some from inside?

Offline

#13 2023-10-06 12:51:39

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Scimmia wrote:

Are you giving us some output from outside the chroot and some from inside?

Here an example according to the changes done during this discussion. I have a fresh Arch Linux environment with "/etc/locale.conf":

LANG=en_US.UTF-8

and "/etc/locale.gen":

en_US.UTF-8 UTF-8

I run "sudo pacstrap /mnt /base" and I get the output of the install of packages of base metapackage and after the install, during the post transactional hooks I get:

(11/12) Warn about old perl modules
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

If I enter by "sudo arch-chroot /mnt" by making its /etc/locale.conf and .gen as the ones of the host (so, with the en_US strings), and then I run "locale-gen" in this chroot, I fix. The problem is that I should fix "before" I run "pacstrap /mnt base" because I would like to manage this warning above produced by running "sudo pacstrap /mnt base".

Last edited by D3vil0p3r (2023-10-06 12:52:36)

Offline

#14 2023-10-06 13:09:14

loqs
Member
Registered: 2014-03-06
Posts: 18,130

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

$ sudo pacstrap /mnt /base
==> Creating install root at /mnt
==> Installing packages to /mnt
:: Synchronizing package databases...
 core is up to date
 extra is up to date
error: database not found: base
==> ERROR: Failed to install packages to new root

Specify LANG=C.UTF8 to use a locale that is prebuilt in glibc,  also I had to add perl  as it is not pulled in by base:

sudo LANG=C.UTF-8 pacstrap /mnt base perl

or install glibc-locales so all the locales are prebuilt

sudo LANG=C.UTF-8 pacstrap /mnt base perl glibc-locales

Note warnings are not errors.
Edit:
Did the warnings you posted result in any issues in the resulting install?

Last edited by loqs (2023-10-06 13:10:20)

Offline

#15 2023-10-06 15:06:16

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 196

Re: [SOLVED] setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Thank you very much. I performed several tests. In my scenario I needed only to run:

sudo pacstrap /mnt base glibc-locales

by keeping "locale.conf" and "locale.gen" unchanged with English entry.

It solved the issue. The warning is not produced anymore.

Offline

Board footer

Powered by FluxBB