Skip to content

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 ( Add comment / trackback )

    1. (permalink)
      Comment by IRaceMyCase
      On February 24, 2012 at 10:30

      Hey halvegare,

      You could also run the following command:

      locale-gen nl_NL.UTF-8

      And you should be on your way.

    2. (permalink)
      Comment by halfgaar
      On March 2, 2012 at 21:23

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

    3. (permalink)
      Comment by halfgaar
      On December 7, 2013 at 11:09

      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. (permalink)
      Comment by Noah Spurrier
      On June 2, 2014 at 07:46

      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.

    Post a comment

    (required)
    (required)

    Your email is never published nor shared.

    (optional)
    Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>