Smokes your problems, coughs fresh air.

Fixing locale message in Ubuntu when logging in or SCPing

I’ve encountered this error occasionally when loggin in:

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

This breaks things like scp or bzr via sftp. To fix it, I followed this advice:

cd /var/lib/locales/supported.d
cat /usr/share/i18n/SUPPORTED|grep -i nl > nl
dpkg-reconfigure locales

It’s not really pretty though; it shouldn’t give an error at all when a locale is missing. I mean, this way, I have to generate every possible locale to support logins from all over the world…

4 Comments

  1. IRaceMyCase

    Hey halvegare,

    You could also run the following command:

    locale-gen nl_NL.UTF-8

    And you should be on your way.

  2. halfgaar

    Thanks for the tip; I’ll try it next time I see this error.

  3. halfgaar

    I found here that putting the following in /etc/environment perhaps also works:


    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8

    That would make logging in from every locale in the world possible, I guess.

  4. Noah Spurrier

    You should only set “LANG=en_US.UTF-8”. Leave out the “LC_ALL=en_US.UTF-8”. The original error can be confusing because LC_ALL is used in two different contexts. The LC_ALL environment variable you are setting in /etc/environment does not refer to the same thing as the LC_ALL in the error message. Also, setting both LC_ALL and LANG would be redundant as the LC_ALL environment variable overrides LANG anyway. Almost always use LANG where people tell you to use LC_ALL. Only use LC_ALL in special cases where there is no other option. Using it at a global level will hide other problems and introduce new ones.

© 2024 BigSmoke

Theme by Anders NorenUp ↑