FS#10428 - [initscripts] locale settings are reset at every reboot

Attached to Project: Arch Linux
Opened by Heiko Baums (cyberpatrol) - Friday, 16 May 2008, 13:33 GMT
Last edited by Roman Kyrylych (Romashka) - Friday, 12 June 2009, 22:53 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Roman Kyrylych (Romashka)
Architecture All
Severity Medium
Priority Normal
Reported Version 2007.08-2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I had a problem with the sorting of the ls output. It was sorted ASCII like and case sensitive, but I need an alphabetically and case insensitive sorting as it is defined in my chosen locale. I also have set my locale settings to "de_DE.UTF-8" but I need LC_MESSAGES="en_US.UTF-8".

So I set my LANG and LC_* environment variables in /etc/profile.d/locale.sh, because I need these settings system wide.

But unfortunately I must notice, that the sort order still isn't changed and my settings in /etc/profile.d/locale.sh are gone after every reboot.

The sort order isn't changed, because in /etc/profile the variable LC_COLLATE is set to "C" independently of the variable LOCALE in /etc/rc.conf. LC_COLLATE is, btw., not necessary to get and keep the system working. If a script needs LC_COLLATE="C" for whatever reason, the command, which needs it, should be prefixed with 'LC_COLLATE="C"' in the script, so that this setting is changed only for this command.

The locale settings are removed at every reboot, because /etc/profile.d/locale.sh is always overwritten by rc.sysinit at every boot time.

To fix this, the files /etc/profile (belongs to package filesystem) and /etc/rc.sysinit (belongs to package initscripts) should be changed, so that the locale settings are not overwritten anymore. User specific settings in ~/.bashrc are not an option, because I need these settings system wide.

The line `LC_COLLATE="C"` should be removed from /etc/profile.
If someone needs another LC_COLLATE than this one set by the chosen locale, this can and should be set manually by the admin himself in /etc/profile.d/locale.sh.

From the file /etc/rc.sysinit the whole "# Flush old locale settings" and "# Set user defined locale" parts should be removed without replacement. See the attached patch.

Additional info:
* package version(s)
filesystem 2008.03-2
initscripts 2008.03-4
* config and/or log files etc.
/etc/profile
/etc/rc.sysinit

Steps to reproduce:
Edit the file /etc/profile.d/locale.sh and set "export LANG=..." and "export LC_...=..." in this file.
Reboot the system.
cat /etc/profile.d/locale.sh
This task depends upon

Closed by  Roman Kyrylych (Romashka)
Friday, 12 June 2009, 22:53 GMT
Reason for closing:  Won't fix
Comment by Aaron Griffin (phrakture) - Friday, 16 May 2008, 15:47 GMT
Uh, no.

Archlinux uses /etc/rc.conf to configure the locale. Your patch completely removes that ability. locale.sh is always autogenerated. Perhaps we need a comment that says "THIS FILE IS AUTOGENERATED, DO NOT EDIT"

What is wrong with setting LOCALE="de_DE.UTF-8" in rc.conf and then doing your *custom* steps in rc.local. That is exactly what rc.local is for. Add "export LC_MESSGES=en_US.UTF-8" to that file and you're gold.

Removing LC_COLLATE is totally unrelated. Please file a different bug report for this - one bug per report please.
Comment by Heiko Baums (cyberpatrol) - Saturday, 17 May 2008, 09:56 GMT
Is it really necessary or useful to set the locale in /etc/rc.conf? I mean, on Gentoo the locales are also set the way, I did, only in /etc/env.d/02locale, which corresponds to /etc/profile.d/locale.sh on Archlinux. Otherwise you indeed should add such a comment on top of this file.

Setting LOCALE="de_DE.UTF-8" in rc.conf, and setting the custom locales in rc.local doesn't work. This only works by setting the custom locales in /etc/profile instead of rc.local. But then you have locale settings at two, actually three different places (/etc/rc.conf, /etc/profile.d/locale.sh and /etc/profile) and /etc/profile is getting not much, but a bit more complex. I think it's better to have the locale settings at only one place. This file could be autogenerated once during the installation - could be edited within the installer, like it is already done with rc.conf - and then be kept untouched like the other scripts in /etc/profile.d. And the file /etc/profile.d/locale.sh is autogenerated and used, anyway. And for the usability I think it doesn't matter, if the user sets the locale in /etc/rc.conf or in /etc/profile.d/locale.sh. I would say, editing /etc/profile.d/locale.sh directly, is a bit more KISS like. This should of course be explained in http://wiki.archlinux.org/index.php/Configuring_locales.

If you like it more to have the locale settings in rc.conf and keep /etc/profile.d/locale.sh being autogenerated, then you probably should add every possible LC_* variable to rc.conf. I'm not quite sure, if this or setting the locales in /etc/profile.d/locale.sh directly is easier.
Comment by Aaron Griffin (phrakture) - Wednesday, 21 May 2008, 23:47 GMT
Again, we're simply debating opinions here. Let's talk about what is "the correct way to set a locale".

If I am on a multi user machine, like the one this bug tracker runs on, which is used by people of at least 4 different locales, what do I do? I set a sensible global locale (in this case, English) and let each user change their own settings in their home dir. If you have custom settings that don't fit into the way we do this, do it on a per-user basis.

That said, I think we can meet somewhere in the middle here. If you were to give me a locale.sh file that would both
a) read LOCALE from rc.conf and use that if defined
b) allow custom overrides in that file
then I would think about implementing it, as it seems feasible. This way we could kill of the autogeneration (which is messy anyway)
Comment by Gavin Bisesi (Daenyth) - Thursday, 11 December 2008, 18:25 GMT
What's the status on this?
Comment by Glenn Matthys (RedShift) - Thursday, 11 December 2008, 20:30 GMT
I see no reason to move LOCALE out of rc.conf. I think it's a logical location to put it. No need to hide it somewhere obscure.
Comment by Thomas Bächler (brain0) - Thursday, 11 December 2008, 21:15 GMT
It's easy to work around this: Create /etc/profile.d/zz.sh and write "unset LC_COLLATE" into that file. Problem solved. As for the locale configuring in rc.conf, I wouldn't change it, it's a central place for system configuration.
Comment by Aaron Griffin (phrakture) - Thursday, 11 December 2008, 21:15 GMT
This bug is still open simply because I don't like the locale.sh autogeneration either. I don't think removing LOCALE from rc.conf is a good idea, but we can meet in-between somehow with a locale script that uses the value from rc.conf and/or allows more complex customization
Comment by Damjan Georgievski (damjan) - Wednesday, 28 January 2009, 16:33 GMT
While I don't mind /etc/rc.conf having a locale setting, it should be noted that the locale is not a system configuration. Your Linux PC can run just fine with no locale setup or even locales installed.

The locale is stricktly a per-user setting, so I ussually suggest people to have it setup in their own ~/.xprofile or ~/.profile
Comment by Heiko Baums (cyberpatrol) - Wednesday, 28 January 2009, 19:16 GMT
Damjan, you're not right. Of course can Linux run just fine without an explicit locale setting, but it only runs fine, because then it uses a standard locale setting (I guess usually en with LC_COLLATE="C"). So the locale is indeed a system configuration. The locales are used for formatting the date and time, for sorting the directory listings etc. So a system wide locale setting is definitively needed.

Locale settings can, of course, also be set on a per-user basis like nearly every other system configuration, but this doesn't mean, that these settings are not system settings.

When somebody's living in Germany or France or whereever, why should he run an English locale system wide?

If it is set system wide, it usually belongs in /etc/profile or for my part also in /etc/rc.conf. If it is set by a user, it belongs to ~/.bashrc or whatever file is sourced at login.
Comment by Roman Kyrylych (Romashka) - Friday, 12 June 2009, 22:53 GMT
Hm, I wonder how I've totally missed this.
1) As for LC_COLLATE=C -  FS#10435  was closed as "Won't fix" and
putting your config lines at the end of profile.sh or, as Thomas suggested, in profile.d/zz.sh will override anything in locale.sh

2) The are a couple of reasons for generating /etc/profile.d/locale.sh instead of doing same settings in rc.sysinit,
for example to make sure that terminal looks okay even after it was reset/broken by user or some crappy program,
This solution existed for ages, and was greatly stabilized during past years while solving different locale-related issues
(actually, my first contribution to Arch was a patch I sent to Judd to fix some locale problems, that was in year 2005).
For the record our current console localization scheme is quite flexible, it even supports things like non-UTF console with different charsets for keyboard and display.
If there are some proposals to extend the configurability of the current scheme in a clean and backwards compatible way - great,
but please open a separate feature request for this, preferably with a patch.
The idea of generating locale.sh during installation and putting info on wiki about editing it may seem good,
but actually this doesn't bring much benefits - most people are fine with current scheme and manual setup of correct localization of console is very tricky (see rc.sysinit for that),
and that's a turnover from our 'keep stuff in rc.conf' idea.
To summarize all - let's not try to "fix" things in this area because there's really nothing broken.
Again, for proposals of more customization without breaking the current scheme - please create a separate feature request.

Loading...