Bug 1374843 - locale improperly set with localectl
Summary: locale improperly set with localectl
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-09 19:58 UTC by Aleksandar Kostadinov
Modified: 2019-07-21 10:37 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-21 10:37:01 UTC
Type: Bug


Attachments (Terms of Use)

Description Aleksandar Kostadinov 2016-09-09 19:58:46 UTC
Description of problem:
User locale is not set properly after DE (XFCE) login and with `bash -l`.

Version-Release number of selected component (if applicable):
systemd 229

How reproducible:
always

Steps to Reproduce:
$ localectl set-locale LANG=en_US.utf8 LC_CTYPE="C.utf8" LC_NUMERIC="C.utf8" LC_TIME="C.utf8" LC_COLLATE="en_US.utf8" LC_MONETARY="C.utf8" LC_MESSAGES="en_US.utf8" LC_PAPER="bg_BG.utf8" LC_NAME="C.utf8" LC_ADDRESS="C.utf8" LC_TELEPHONE="C.utf8" LC_MEASUREMENT="C.utf8" LC_IDENTIFICATION="C.utf8"

# reboot

$ locale
@@@ LANG=C.utf8
LC_CTYPE=C.utf8
LC_NUMERIC=C.utf8
LC_TIME=C.utf8
LC_COLLATE="C.utf8"
LC_MONETARY=C.utf8
LC_MESSAGES="C.utf8"
LC_PAPER=bg_BG.utf8
LC_NAME=C.utf8
LC_ADDRESS=C.utf8
LC_TELEPHONE=C.utf8
LC_MEASUREMENT=C.utf8
LC_IDENTIFICATION=C.utf8
LC_ALL=

$ sudo su - myuser
$ locale
@@@ LANG=en_US.utf8
LC_CTYPE=C.utf8
LC_NUMERIC=C.utf8
LC_TIME=C.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=C.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=bg_BG.utf8
LC_NAME=C.utf8
LC_ADDRESS=C.utf8
LC_TELEPHONE=C.utf8
LC_MEASUREMENT=C.utf8
LC_IDENTIFICATION=C.utf8
LC_ALL=


Basically doing `bash -l` doesn't help. Doing `sudo su - user` does help and LANG is properly set. But no other attempts help to have properly set LANG variable as configured by `localectl`.

Comment 1 Fedora End Of Life 2017-07-25 22:56:34 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 2 Zbigniew Jędrzejewski-Szmek 2017-07-27 12:32:13 UTC
localectl causes /etc/locale.conf to be updated with the new settings, and systemd will use this to set the environment of lightdm (or other login manager). But after you log in, those settings can be influenced by various other things, including at least the display manager and /etc/profile.d/lang.sh, which reads ~/.i18n.

Since the settings for root match what you configured with localectl, it seems some other component resets the locale. Please do the following:

- run "pstree -aps $$" to see a list of ancestors of your shell
- look at each process's environment with "cat /proc/PID/environ | tr '\0' '\n'" where PID is each process number. You'll need so prefix this with 'sudo' for system processes.
- you should see LANG=en_US.utf8 switch to LANG=C.utf8 at some point... This should be the place where the issue is.

Comment 3 Aleksandar Kostadinov 2018-01-14 10:35:34 UTC
Sorry, this fell under my rather. This is Fedora 27 now. I'm not sure pstree is very helpful. When terminal is started, it falls to parent "1".

> $ pstree -aps $$
> systemd,1 --switched-root --system --deserialize 24
>   └─xfce4-terminal,2543
>       └─bash,6687
>           └─pstree,31427 -aps 6687
> 
> $ cat /proc/2543/environ | tr '\0' '\n' | grep LANG
> LANG=C.utf8
> $ sudo cat /proc/1/environ | tr '\0' '\n' | grep LANG
> LANG=en_US.utf8

Still `bash -l` doens't help:

> $ bash -l
> $ echo $LANG
> C.utf8

`sudo su -` still helps though

> $ sudo su - user
> [sudo] password for user: 
> $ echo $LANG
> en_US.utf8

I don't think I have any customization wrt LANG, my first attempt at setting it was with `localectl`:

> $ grep LANG ~/.*
> grep: /home/user/.: Is a directory
> grep: /home/user/..: Is a directory
> ...

I don't know how is systemd supposed to set LANG but it doesn't work for all sessions.

Comment 4 Aleksandar Kostadinov 2019-05-27 05:33:20 UTC
Now with Fedora 30 I do see LANG properly set under XFCE. I don't know what changed.

> 🐚 localectl status
>    System Locale: LANG=en_US.utf8
>                   LC_CTYPE=C.utf8
>                   LC_NUMERIC=C.utf8
>                   LC_TIME=C.utf8
>                   LC_MONETARY=C.utf8
>                   LC_PAPER=bg_BG.utf8
>                   LC_NAME=C.utf8
>                   LC_ADDRESS=C.utf8
>                   LC_TELEPHONE=C.utf8
>                   LC_MEASUREMENT=C.utf8
>                   LC_IDENTIFICATION=C.utf8


Then

> 🐚 set |grep LANG
> LANG=en_US.utf8

Comment 5 Zbigniew Jędrzejewski-Szmek 2019-07-21 10:37:01 UTC
OK, let's close then.


Note You need to log in before you can comment on or make changes to this bug.