Locale error despite consistent locale-gen

I am having trouble getting certain AUR and flatpak apps to run with UTF-8 characters. Anki reports Anki requires a UTF-8 locale. Please Google 'how to change locale on [your Linux distro]', and MusicBee (via Wine) cannot read files with UTF-8 characters in their names.

Originally these were only an issue when launching the apps normally (double clicking a .desktop in dolphin, or launching via the KDE application launcher). When I would launch the apps via bash (Konsole) there would be no issues. Even running a shell script to launch the desktop file would work via Konsole but not via Dolphin. However I recently removed some extraneous (I thought) locale definitions from my .bashrc, and now neither work.

As far as I can tell, my locales are set and generated as I would want, with the right lines uncommented from /etc/locale.gen:

# locale
LANG=en_GB
LC_CTYPE="en_GB"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=C
LC_COLLATE="en_GB"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_GB"
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=

# locale -a
C
C.utf8
en_GB
en_GB.iso88591
en_GB.utf8
en_US
en_US.iso88591
en_US.utf8
POSIX

I am running these from the same bash instance as I attempt to launch the faulty programs from.

What can I do to troubleshoot this further?

That’s not the locale.gen file.

The locale.gen file entries for GB should look like this

en_GB.UTF-8 UTF-8

What you posted is the locale.conf file. Or am I misinterpreting your comment?

I’ve sent the results of running locale and locale -a. My locale.gen looks like:

#aa_DJ.UTF-8 UTF-8  
#aa_DJ ISO-8859-1  
#aa_ER UTF-8  
...
#en_DK ISO-8859-1  
en_GB.UTF-8 UTF-8
en_GB ISO-8859-1
#en_HK.UTF-8 UTF-8  
...
#en_SG ISO-8859-1  
en_US.UTF-8 UTF-8
en_US ISO-8859-1
#en_ZA.UTF-8 UTF-8  
...

and my locale.conf looks like

LANG=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_MONETARY=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_NUMERIC=en_GB.UTF-8
LC_PAPER=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_CTYPE=en_GB.UTF-8
LC_ALL=en_GB.UTF-8

Comment the iso lines.

No change in behaviour- I assume generating excess unused locales doesn’t affect errors.

What is that you want, if I am not intrusive? :smile:
Do you need ISO-* locales for some reason?
Locale configuration is done according to technical considerations. What do you want to achieve?

I doubt this is true, if in the meantime you have not modified other settings/files.

And now, the real question:
What session are you running? (Maybe some Plasma/KDE?)

env | grep -iE "xdg_(current|session)_desktop"
systemctl show-environment | grep LANG 
systemctl show-environment --user | grep LANG

I purely want to run programs with unicode characters without errors. Them being set as I want is referring to my locale.conf being all en_GB and it being generated.

# env | grep -iE "xdg_(current|session)_desktop"
XDG_SESSION_DESKTOP=KDE
XDG_CURRENT_DESKTOP=KDE

# systemctl show-environment | grep LANG 
LANG=en_GB.UTF-8

# systemctl show-environment --user | grep LANG
LANG=en_GB
LANGUAGE=en_GB

It certainly does, though it may be through my editing it in the past. I’m not sure what other settings/files might be relevant?

Then you must disable the ISO* locales in locale.gen and regenerate locales.

And, yes, it’s KDE! :crystal_ball: :tada:

Your system locale is correctly set, but KDE does not have the same settings. Go in System Settings Locale/Language (whatever) and set the same (UTF-8) locales.
Reboot to see differences.

It seems that may have been important. :wink:

Thanks for the help.

Followup questions- What did it change in my files to re-set the location setting to what it was displayed as being already set as (British English), and restart? It doesn’t appear to have changed my .bashrc, nor locale.conf. It seems like my .bashrc solution which I reverted only solved the issue when launching via bash, so does launching via the desktop bypass that?

I’m afraid I don’t understand the question. Can you rephrase?

What exactly have you done and what was in .bashrc, what did you add/restore? Confusing… Sorry.

In Settings > Region & Language > Language it was listed as “British English”. I clicked modify and selected “British English”, it prompted me to restart. Now the problem is gone. All programs behave as expected. However, looking in my /etc/locale.conf, everything is exactly as I showed above, and nothing has been added to my ~/.bashrc. What did the settings change on my system then?

As for my previous bashrc content that was fixing the programs but only when launched via commandline, I am sure I added it myself a long time ago when trying to set up fcitx or similar. Is there a place to put options like that which applies to programs launched outside of commandline (i.e. double clicking in kate or running via app launcher)?

This writes/modifies some KDE-related files in ~/.config/, as these are what KDE is using (user session), instead of system settings. Check modification timestamps to confirm what was changed.

It depends on the options and what you are trying to do (apps, features, etc.).
For command-line programs, you can use .bashrc, or other (.profile, etc.) to add commands/EnvVars.
For desktop launched apps in KDE, you have to follow the KDE way (System Settings, or some addon). It also depends on the specific task. :man_shrugging:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.