Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Error when login as pi
#1
Hi,

when you currently login outside of GB into the pi account you will get an error like this:
-bash: warning: setlocale: LC_ALL: cannot change locale (de_DE.UTF-8)
to get rid of this error do the following steps:

sudo vi /etc/locale.gen

Search your locale setting ( e.g. de_DE.UTF-8)  and un-comment that line (delete the '#' ) and save the file ( you could keep en_GB.UTF-8)
then let your locales generate by :
sudo locale-gen

you will see something like:
Generating locales (this might take a while)...
  de_DE.UTF-8... done
  en_GB.UTF-8... done
Generation complete.
Reply
#2
I'm located in US and thus outside of GB.

How can I reproduce this ?
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(12-07-2020, 01:46 PM)Tim Curtis Wrote: I'm located in US and thus outside of GB.

How can I reproduce this ?

just login as user pi through ssh and you will normal get this error. Especially when you have setup LC_ALL or LC_CTYPE in your remote environment. ssh is passing that environment partial to the client ( moode)

Or you try to set us_US.UTF-8 or something like us_..... as LANG in your profile ( .bashrc ) 
As the locale files are growing more and more, the standard setup of RPi has not all locale included. So in case you are not out of the country of RPi you need to setup and create your own locale. Hope that helps ?
Reply
#4
I've never seen this on stock moOde and I don't recall any trouble reports of anything like this.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
The OP asserts


Quote:just login as user pi through ssh and you will normal get this error. Especially when you have setup LC_ALL or LC_CTYPE in your remote environment. ssh is passing that environment partial to the client ( moode)

Actually, the ssh man page says (Linux Mint and RaspiOS, both based ultimately on Debian):

Code:
   ssh will normally set the following environment variables:
...LANG and LC variables are not mentioned in the list, but then...
     Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
     “VARNAME=value” to the environment if the file exists and users are al‐
     lowed to change their environment.  For more information, see the
     PermitUserEnvironment option in sshd_config(5).


and on the moOde player, the sshd_config man page says


Code:
   PermitUserEnvironment
            Specifies whether ~/.ssh/environment and environment= options in
            ~/.ssh/authorized_keys are processed by sshd(8).  Valid options
            are yes, no or a pattern-list specifying which environment vari‐
            able names to accept (for example "LANG,LC_*").  The default is
            no.  Enabling environment processing may enable users to bypass
            access restrictions in some configurations using mechanisms such
            as LD_PRELOAD.


Examining the /etc/ssh/sshd_conf file on the moOde player, I see the option in question is commented out


Code:
#PermitUserEnvironment no

hence, sshd chooses "no" by default.

I conclude the OP has been changing settings.

=====

As a check, first a look at my stock moOde player:


Code:
pi@moode3a:~ $ locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
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=

While for my Linux Mint box


Code:
kreed@xenon:~$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

kreed@xenon:~$ ls -l .ssh/environment
ls: cannot access '.ssh/environment': No such file or directory


As expected from my reading of the man pages, and as Tim said, I don't see the issue when I ssh to a stock moOde player from the Linux Mint box. 

======

Certainly one can get into interesting situations with locale settings. My thought is, wait for the problem actually to arise and then try the OP's solution.

Regards,
Kent
Reply
#6
Rainbow 
I don't have ssh environment setup on my moode players. So e.g. the LANG is not set from ssh. I also tried to setup LANG on my host before ssh'ed to the Moode RPI: there LANG was again en_GB.UTF-8, so the ssh environment is not used without a special setup in .ssh/config or /etc/ssh/sshd_conf. 
I have not changed that setting yet, but will to prevent password challanges.(diffrent story)

As I am using zsh, I am no expert of bash. In zsh, there are some global configuration files like /etc/zshenv where you normaly setup such Lxx environment. Maybe that is the same case for bash.

A second guess is, as I change my keyboard layout in moode to DE, Moode/Phyton maybe is changing some locales.
Anyhow, my intend was: if somebody has this error, when she is using ssh to connect, ,she could easy follow my instruction to create the required locale. After that setup, the error is gone. (in the moode image, only en_GB.UTF-8 exists)

No blames, no fingerpointing; just a thread I thought that will fit under FAQ and guides 

I don't want to remind you about the mars rover that crashed during landing as the software out of GB was using metric , while US has used inch - some locales really make the diffrence :Big Grin  <I am running ... >
Reply
#7
I tried setting the keyboard to DE on my player, I see no errors about locale. It would be great to track down what's setting this in your system.
----------------
Robert
Reply
#8
(12-08-2020, 10:00 AM)the_bertrum Wrote: I tried setting the keyboard to DE on my player, I see no errors about locale.  It would be great to track down what's setting this in your system.

Hmm, I grep'ed all bash files in /etc and ~/ and have not received any hint on locale or setting LC_ALL

PAM is reading and setting /etc/default/locale 
Code:
cat /etc/default/locale
LANG=en_GB.UTF-8


what explains , why en_GB.UTF-8 is the standard. This is also created by /usr/bin/raspi-config - do_change_locale()
As the error was posted by bash, I assume BASH is the source. I cant verify, but /usr/share/bash-completetion/completions/localectl will change locale. If this completion is read by bash at the beginning is not something I know ( remember I am using zsh) 
I only can say theerror was always right after the connection to my moode-hw's with ssh. "Was" as this is a) fixed with the generation of the locale and b) no longer relevant for my usage as I installed and switched to my lovely homeshell zsh Big Grin
Reply
#9
Beside what I have written, there is another default in the OS:
the file /etc/ssh/sshd_configj contains as standard
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Now saying that , you normally must use 'SetEnv' to set these vars in the ssh_config - which is also a standard in /etc/ssh/ssh_config
So that could be also the source of the error

Intersting: if you have enabled PAM in sshd_config ( by UsePAM yes - which is standard) and you have also PermitUserEnvironment no then ssh will not read /etc/environment BUT PAM will do so Big Grin
( PAM will also allow passwords even when you only allow PublicKey Authentication in sshd_config ) Both are standards in PAM on every system
Reply
#10
The wonderful thing about Linux is that there is more than one way to do anything and they are often conflicting/contradictory ways Tongue 

We know moOde is built on stock Raspberry Pi OS Lite and inherits from it such things as the GB locale (cuz, you know. the RPF is in England and proud of it)---not to mention the ssh/d, PAM, and other configurations.

So far, the few of us who have responded here have been able to replicate your logon experience nor have users mentioned it on the forum before but, sure enough, I searched the InterWeb™ and my first hit was a blog entry from 6 years ago Fixing Your Locale on Raspberry Pi.

I'm content to let the first post in this thread be the guide for folks who sail into this particular rock.

Regards,
Kent
Reply


Forum Jump: