[Nix-dev] Set locale in a pure nix-shell
Mateusz Kowalczyk
fuuzetsu at fuuzetsu.co.uk
Wed May 14 02:54:42 CEST 2014
On 05/10/2014 12:50 AM, Shea Levy wrote:
> Are there actually builds whose behavior changes based on LANG? Maybe
> nix-shell can special-case it even for --pure?
I encountered this in practice today when working with GHC: if we're not
using unicode locale, GHC will print `like this' instead of ‘like this’
and many test cases fail.
> On Fri, May 09, 2014 at 11:44:47PM +0400, Kirill Elagin wrote:
>> Ok, as it always happens, immediately after sending the message I realised
>> that I need `LOCALE_ARCHIVE` in the environment.
>> So `glibcLocales` is no needed at all, it's just enough to point
>> `LOCALE_ARCHIVE` to the system locale archive.
>>
>> But the question remains. I feel that setting locale by default to
>> something more reasonable than POSIX might be a good idea…
>>
>>
>> --
>> Кирилл Елагин
>>
>>
>> On Fri, May 9, 2014 at 11:38 PM, Kirill Elagin <kirelagin at gmail.com> wrote:
>>
>>> `nix-shell --pure` resets locale to POSIX and this leads to issues with
>>> unicode output.
>>> For example:
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> % nix-shell --pure
>>>
>>> [nix-shell:~/tmp/shell-test]$ cat test.py
>>> print('かわいい')
>>>
>>> [nix-shell:~/tmp/shell-test]$ python3 test.py
>>> Traceback (most recent call last):
>>> File "test.py", line 1, in <module>
>>> print('\u304b\u308f\u3044\u3044')
>>> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3:
>>> ordinal not in range(128)
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> I'd like to use some utf-8 locale (maybe `en_US.UTF-8` should be even used
>>> by default?), but I have no idea what to do to make other locales available
>>> inside a pure shell. Adding `glibcLocales` doesn't seem to make any
>>> difference.
>>>
>>>
>>> --
>>> Кирилл Елагин
>>>
>
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
--
Mateusz K.
More information about the nix-dev
mailing list