Feb 7, 2017

Raspberry Pi - The problem about "cannot change locale"

After having problem at configuring Internationalisation to en_US.UTF-8 with raspi-config,
error messages below keep popping up every time I login to my raspberry pi.

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
and

pi@raspberrypi:~ $ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = "en_US.UTF-8",
 LC_CTYPE = "UTF-8",
 LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory


And there are bunch of locale warning during my apt-get install which is really annoying even though I am not sure how it does affect my apt-get installation even when the installation is successful.

Raspi-config internationalisation options screen
Every retry of locale change end up here in the error message below, you stuck here forever and that's it!
Change Locale Error
I've tried looking for solution, and I am lucky enough end up in the links at the bottom of this article.
The solution is simple:

  1. sudo nano /etc/locale.gen
  2. uncomment your preferred locale, for example en_US.UTF-8
  3. sudo locale-gen en_US.UTF-8
  4. sudo update-locale en_US.UTF-8

Even though it help getting rid of the annoying 'cannot change locale' or '' error message in your terminal,
it doesn't fix the "There was an error running option I1 Change Locale" issue.
As I tried reconfigure Locale changes, raspi-config will still return me to the same error as in Change Local Error screenshot above.

So until now, I'm still looking for the root cause of this problem.

TL; DR
Solution on StackOverflow - Unable to reconfigure locale in raspberry pi
Original solution source was blog years ago Raspberry Pi -- Fixing your Locale