FS#56688 - [filesystem] export $LANGUAGE
Attached to Project:
Arch Linux
Opened by nl6720 (nl6720) - Tuesday, 12 December 2017, 08:30 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 10 January 2019, 03:38 GMT
Opened by nl6720 (nl6720) - Tuesday, 12 December 2017, 08:30 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 10 January 2019, 03:38 GMT
|
Details
Description:
/etc/profile.d/locale.sh exports all locale.conf supported variables except LANGUAGE. Please add: [ -n "$LANGUAGE" ] && export LANGUAGE to locale.sh Additional info: * package version(s) * config and/or log files etc. filesystem 2017.10-2 Steps to reproduce: set LANGUAGE in /etc/locale.conf, relogin and run: printenv LANGUAGE |
This task depends upon
Closed by Eli Schwartz (eschwartz)
Thursday, 10 January 2019, 03:38 GMT
Reason for closing: Fixed
Additional comments about closing: filesystem 2018.1-2
Thursday, 10 January 2019, 03:38 GMT
Reason for closing: Fixed
Additional comments about closing: filesystem 2018.1-2
I understand that there is no guarantee (may not) but not it's forbidden (must not).
LC_ALL is commonly a last resort override variable. localectl explicitly doesn't list or support LC_ALL.
$ export notavar
$ declare -p notavar reallynotavar
declare -x notavar
bash: declare: reallynotavar: not found
```
I did not realize export had that effect on unset variables, but I think it should be harmless as bash still seems to consider it unset.
Anyway, regarding LC_ALL, it should be fine to export it. The reason it should not be set in locale.conf(5) is not because it shouldn't be used, merely that it should only be used in explicit circumstances. Exporting it *in those circumstances that it is already set* seems to be the right choice I guess.
If I copy /etc/locale.conf to ~/.config/locale.conf and relogin both are set correctly.
echo "$LANG" in locale.sh spits out "C" before the LANG=${LANG:-C} line is executed, so the assumption that systemd does this may not be quite correct.
From getty@.service :
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
A workaround appears to be copying /etc/locale.conf to XDG_CONFIG_HOME/locale.conf
So things remain broken.
So, I will stop exporting it in next release.
About locales not set for getty services, this is something done by systemd upstream on purpose and we, until now, override it by mistake.
If there is no more issue and UnsetEnvironment in the getty@.service can be removed, I suggest you to contact upstream to make this fixed in all distribution.
If this can be overridden only in your case, you can remove the UnsetEnvironment= by a partial overrides in /etc/systemd/system/getty@.service.d/
If upstream decides that there is nothing to fix, and reaffirms their belief that it should be set in a post-login shell... are we just going to say "no, systemd should do it", and leave *locale* broken as a matter of Arch policy?
Upstream leaves this up to the distributors to solve and I highly doubt they will change their stance.
a)remove the UnsetEnvironment line in getty@.service in the systemd packages and let users deal with the funny question-marks when using the linux console (minor issue since they will get them anyway, just for different characters)
b)work the locale.conf changes back into locale.sh in a fashion that lets users still override them from the kernel commandline (is this ever useful on anything that is not a "live CD"?)
Certainly systemd is wrong to unset the environments because it's frankly none of their business as to whether or not the console "has issues" or not, but through misguided "good intentions" they do so anyway to shield users from any potential issues.
Likewise it is wrong for Arch to break functionality like this and do nothing about it. The least they could have done is either revert the changes and then start thinking of a new mechanism, or, change the mechanism to test an alternative (i.e. this is what [testing] is for).
PS: *Never* export LC_ALL (why was this even considered?). Users can do that themselves. They may load the gun and shoot their own feet, but Arch (or any distro) shouldn't be complicit in doing the latter on their behalf.
@Eli: The systemd policy was well summed by Lennart in the bug report pointed by nl6720: «... the system locale should be read and set at one place, and not at multiple, and that one place should be PID 1.» This is precisely what I attempted to achieve. I presumed (wrongly) that our locale.sh was loading /etc/locale.conf because it was from a pre systemd era and has never be cleaned since, that's why I improperly used the «by mistake» stanza.
Despite this ambitious target, they decided to workaround a getty issue with CIJK languages by relying on distro shell scripts: «Hence, for now don't pass any locale settings to getty/login, and thus rely on the classic post-login script fragment to set and fix the locale.». I didn't know that and that change the story.
@Alexander: Your b) proposal make sense but I only reverted the loading of /etc/locale.conf in 2018.1. I have no time and interest in developing something to parse the kernel command line. Not to mention, that systemd environment (and so locales) can be overrode by others mechanism.
@Earnestly: Unhelpful answer: Go teach your opinions to Intel engineers, they deserve your help in that moment and your story about guns.
@Evangelos: Do you know what's happen? Is slim which reset the whole environment or this is specific to locales?
@Doug: Why did you wait 4 days to claim that your locales was totally broken? Only the regression on getty was reported until today.
What do you mean by totally broken, is there something else than getty (and slim) broken by letting PID1 define the locales for the system?
A request for a quick fix would do the job as well that «stop this insanity», so there is a 2018.1 in testing with a quick fix. Hope you enjoy.
Unless all login methods can be relied upon to preserve the system locale for user sessions, it is likely that locale.sh will need to read the system locale for the foreseeable future, as inelegant as it may be.
Like Earnestly, I wasn't bothering waiting for a fix for my own machines, was just frustrated that people were continuing to experience this with no response in sight.
@Sébastien: The changes in filesystem 2018.1-1 seem to be the most appropriate course of action; cheers for the quick fix. Please note that LC_NAME is exported twice and LC_PAPER got lost after the changes. I'd suggest generating the list programmatically to avoid such issues; something like running the following command and then copy-pasting the output to locale.sh: https://paste.xinu.at/wvZ/
I have a few questions though:
(1) In locale.sh we use [[ -n "$VAR" ]], is it important that the variable is set but empty, and does it make a difference to test for unset $VAR with [[ -v VAR ]]? I don't know all possible issues (security-related as well) associated with locales because myself I mostly use C/POSIX locale.
(2) Sourcing _anything_ from files in $HOME in a system-wide script seems wrong. Do we have to do it?
(3) AFAIU, XDG_variables are for GUIs, no? Why these vars are being tested at all? What sets XDG_CONFIG_HOME other than a display manager. For example, on my machine, $XDG_CONFIG_HOME is not set and I'm using xfce4 started via startx(1).
(0.5) Claiming that it is "not true that this change created lots of breakage" because you mostly use C/POSIX locale is far more laughable than the previous accusations about the change itself. Please do not come to the bugtracker merely to talk about how your personal lack of breakage means there isn't a problem.
It is one thing for us to debate what the proper fix is and (maybe) disagree about whose fault it is... it is another thing entirely for you to stick your head in the sand and claim that there is no problem for all other Arch users.
(1) [[ -v VAR ]] is a bashism, and locale.sh is and must be POSIX-compatible.
(2) Yes, it is not a "system-wide script" it is a "system-wide rc file loaded by a user-level interactive shell". It makes an incredible lot of sense to do so.
(3) You have completely misunderstood it, then. XDG standards have nothing to do with GUIs at all. XDG is used for allowing users to relocate the default ~/.config location for a wide variety of user configuration files, across GUI, CLI, TUI, and daemonized software. It is never set by display managers, it is in fact set by ~/.pam_environment or ~/.bashrc or whatever, and if not explicitly set by the user it is defined that applications should fall back on ~/.config.
(0) Pls search this thread for comments by Doug. I thought that LC_ALL is something evil...
(0.5) I'm just saying that the amount of comments is not commensurate with the seriousness of this issue. Why would you mask locale.sh in pacman.conf if all you need to do is "cp /etc/locale.conf $HOME/.config"??
(1) OK, yes, you are right. Since Arch uses bash as a system shell in all scripts like mkinitcpio and pacman-key, I thought it is appropriate in locale.sh. Still, you didn't answer my main question :) I'll do some research.
(2) If a file being sourced in ~/.config is broken, this will become obvious at every login. Otherwise, this breakage must be enabled from .bash{rc,_profile}
(3) My question was which applications :) And if it is set by user shell init files, how can this possibly work??? bash(1) manpage says that /etc/profile is loaded *before* stuff in ~ (by default of course).
> (2) Sourcing _anything_ from files in $HOME in a system-wide script seems wrong. Do we have to do it?
For what it's worth, this is the locale.sh (locale2.sh) script I used to replace the one from filesystem: https://ptpb.pw/cy_i/sh
(1) LC_*="" will do strange and wonderful things to prevent inheriting $LANG, but that is really the user's fault. There is no nice POSIX way to test for a set, empty variable (well, I guess we could use ${var+x} but I did specify "nice" :D ), so we might as well fix broken variables I guess? But we no longer bother with that, which is fair because if the user sets LC_*="" then they should probably expect breakage.
Breaking dash or busybox ash for no good reason with syntax errors is a no-no, though. And [[ -v VAR ]] doesn't have any real benefit over exporting it just in case.
(2) If you enable it from ~/.config/locale.conf, then you have enabled it.
(3) It may be unlikely anyone will use `bash -i` in an existing interactive shell, but pam runs before bash and will load this. You could do something like:
```
# XDG compliance, explicitly set fallback values Just In Case™
XDG_CACHE_HOME DEFAULT=@{HOME}/.cache
XDG_CONFIG_HOME DEFAULT=@{HOME}/.config
XDG_DATA_HOME DEFAULT=@{HOME}/.local/share
```
Eli:
(0.5) Yes, my point exactly :) When systemd breaks things like that (see IP sandbox for logind) ppl are happy to change their systems in non-trivial and obscure ways, but when filesystem package introduces a trivial breakage, everyone complains as hell?
(1) Ok, I understand :)
(2) I *brutally* disagree. .bashrc and .bash_profile are documented files, but where is ~/.config/locale.conf documented? Hell, you don't even suggest to parse it, just blindly source? Fantastic!
(3) I can do arbitrarily stupid things, but why do I want to set XDG var in a special .pam_env file? Just to conform to FDO?
~/.config/locale.conf is documented where all Arch specific documentation belongs: https://wiki.archlinux.org/index.php/Locale#Overriding_system_locale_per_user_session
As for XDG vars, the reason (when you are not blatantly showing an instructional example) is that one would want to *not* conform to anything, and set their own. If the variable doesn't exist, locale.sh conforms to XDG standards and falls back on ~/.config, so I'm really not sure what the issue is.
And BTW, no other file in the /etc/profile hierarchy cares about files in $HOME or $XDG*.
@Evangelos: Damn, I made this mistake when I tried to optimize the output on 2 lines. I used your script to push a 2018.1-2. Thanks.
@Doug: This change was pushed 31/12 in the evening and roll-backed 4th in the night as soon I get there is a real impact. Before, it was unclear to me if I have the time to find a proper fix to keep the direction or if we have to rollback in emergency. So, yes get feedback from known people like you help. Putting aside that we are in testing, in the middle of the new year eve, I understood your frustration and I'm sorry for that.
I have few quesions:
- What are the technical grounds of your opinion on LC_ALL was a «serious WTF»?
- Your machines are all in testing?
- I used to think that our users are mosting login via a graphical login manger or ssh. Except iso image, which was not hit by that, what usage can be to use getty?
@Bartłomiej: I can share with you about filesystem that I was too optimistic on the change, chose a bad window and didn't took the required time to test. So, there is room for improvements. It's good that you choose cups as an example. I didn't got answer to my question from the maintainer on a-d-p last September. When a bug was open (
FS#56818) in late December, I asked and waited for opinions about solutions from several maintainers, to not make people unhappy and don't get complain from you. But, you are still and expecting that the fix come from filesystem where it could have been done by the maintainer month ago, which know cups best than me.Some systems, unfortunately, set LC_ALL in /etc/profile or in similar initialization files. As a user, you therefore have to unset this variable if you want to set LANG and optionally some of the other LC_xxx variables."
https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html
LC_ALL should not be exported by default, it is there for debugging and very few other use-cases.
I assume that the WTF was caused by you shredding locale.sh despite the unfamiliarity with LC_ALL (or how the LC_* vars work in general).
https://wiki.archlinux.org/index.php/Getty#Automatic_login_to_virtual_console