You are not logged in.

#1 2016-03-24 08:14:42

neutronst4r
Member
Registered: 2016-02-25
Posts: 31

[Solved] Messed up locale settings

Since yesterday some of my python applications (ranger, py3status) no longer work and throw the error:

ranger version: 1.7.2, executed with python 3.5.1
Locale: None.None
Current file: None
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/ranger/core/main.py", line 121, in main
    fm.initialize()
  File "/usr/lib/python3.5/site-packages/ranger/core/fm.py", line 118, in initialize
    self.ui.initialize()
  File "/usr/lib/python3.5/site-packages/ranger/gui/ui.py", line 82, in initialize
    self.setup()
  File "/usr/lib/python3.5/site-packages/ranger/gui/ui.py", line 242, in setup
    self.console = Console(self.win)
  File "/usr/lib/python3.5/site-packages/ranger/gui/widgets/console.py", line 44, in __init__
    for line in f:
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 843: ordinal not in range(128)

ranger crashed.  Please report this traceback at:
https://github.com/hut/ranger/issues

I don't now whether it was something I did (probably) or not. I have removed all packages installed since then and tried to revert all changes, but I can't put my finger on the exact source. I think something in my user settings is overwriting my locales because logging in as a different user in a tty console I can run ranger and lsblk without errors. Manually setting the LANG variable for ranger works, but it does nothing for lsblk.

Something that does work:

$ export LANG=en_US.UTF-8; ranger

Surprisingly the output of lsblk in an XTerm terminal is okay, however in urxvt it looks like this:

/home/neutronst4r neutronst4r@Archy% lsblk
NAME     MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda        8:0    0 232.9G  0 disk  
ââsda1     8:1    0   190M  0 part  /boot
ââsda2     8:2    0     1K  0 part  
ââsda5     8:5    0   9.3G  0 part  
â ââswap 254:1    0   9.3G  0 crypt [SWAP]
ââsda6     8:6    0 223.4G  0 part  
  ââmain 254:0    0 223.4G  0 crypt /
sdb        8:16   0   1.4T  0 disk  
ââsdb1     8:17   0     1K  0 part  
ââsdb5     8:21   0   1.4T  0 part  
  ââhdd  254:2    0   1.4T  0 crypt /Storage

ranger on the other hand works in neither terminal.

Some more information. (I have no ~/.config/locale/locale.conf):

/home/neutronst4r neutronst4r@Archy% cat /etc/locale.conf
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
/home/neutronst4r neutronst4r@Archy% cat /etc/environment 
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#

en_US.UTF-8 is of course uncommented in locale.gen and gen-locale has been run successfully.

/home/neutronst4r neutronst4r@Archy% python
Python 3.5.1 (default, Mar  3 2016, 09:29:07) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>> 

Last edited by neutronst4r (2016-03-24 16:29:38)


makepkg not war

Offline

#2 2016-03-24 08:24:50

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,536

Re: [Solved] Messed up locale settings

What says

$ localectl

. But better you have a look at the wiki


do it good first, it will be faster than do it twice the saint wink

Offline

#3 2016-03-24 08:49:13

neutronst4r
Member
Registered: 2016-02-25
Posts: 31

Re: [Solved] Messed up locale settings

/home/neutronst4r neutronst4r@Archy% localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: de
      X11 Layout: de

I just tried "xterm -u8" and all programs work fine in this terminal, however regular shell commands in and out off urxvt still don't work. I did read the wiki, but I don't know what else there is I could try. These commands all don't work:

export LC_ALL=en_US.UTF-8; lsblk
export LC_ALL=en_US.UTF-8; py3status -c <config file>

ranger does work however... by exporting LANG or LC_ALL first.

Last edited by neutronst4r (2016-03-24 08:50:07)


makepkg not war

Offline

#4 2016-03-24 13:20:28

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,536

Re: [Solved] Messed up locale settings

Try

$ export LC_ALL=C; lsblk

The second program, I don't use it.


do it good first, it will be faster than do it twice the saint wink

Offline

#5 2016-03-24 16:29:04

neutronst4r
Member
Registered: 2016-02-25
Posts: 31

Re: [Solved] Messed up locale settings

Okay, I fixed it now by adding the following to by .zshrc.

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

Somehow zsh, which is my default shell, does not respect the environment variable LANG set in /etc/locale.conf. Without the lines above, the output of "locale" looks like:

/home/neutronst4r neutronst4r@Archy% locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

Thanks for the help.

Last edited by neutronst4r (2016-03-24 16:29:22)


makepkg not war

Offline

#6 2016-03-24 16:47:42

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,737
Website

Re: [Solved] Messed up locale settings

I appreciate that you have marked this thread as solved, but here are some things to check:

1. Have you modified /etc/zsh/zprofile? It should sourcing /etc/profile, if nothing else.
2. Have you modified /etc/profile? It should have a if-for block that tests and sources the .sh files in /etc/profile.d (which includes locale.sh)
3. Have you modified /etc/profile.d/locale.sh? By default, it should read and set the locale from $XDG_CONFIG_HOME/locale.conf, $HOME/.config/locale.conf, or /etc/locale.conf, depending on which files exist (and are readable).
4. If you have all of the above files, and have not modified them (or haven't altered them in a way that breaks the above functionality), check whether $XDG_CONFIG_HOME/locale.conf or $HOME/.config/locale.conf exist and if they do, make sure they correctly specify the locale you want.
5. If all the above checks out, check that all these files are readable by your user.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#7 2016-03-24 17:49:00

neutronst4r
Member
Registered: 2016-02-25
Posts: 31

Re: [Solved] Messed up locale settings

1. Have you modified /etc/zsh/zprofile? It should be sourcing /etc/profile, if nothing else.

Uhm that file didn't exist. I just removed zsh with "pacman -Rn" and reinstalled it, it created it with the following line:

emulate sh -c 'source /etc/profile'

I suppose that was it, because now it works without the extra LANG variable lines. Thanks and sorry for wasting everyones time hmm


makepkg not war

Offline

#8 2016-03-24 18:42:56

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,737
Website

Re: [Solved] Messed up locale settings

Yep, that'll have been it. Locale setting is a fickle beast. If you break a single link in that source chain, your locale won't get set correctly (without workarounds at least). You might want to find out why that file disappeared (check your command history), but if you've learnt how zsh sets your locale by reading through those files, then it's not a waste of time. wink


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB