40

When I press tab for autocompletion I get this error:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

I've tried running this:

locale-gen en_US en_US.UTF-8
dpkg-reconfigure locales
reboot

But it doesn't help. Do you know what is missing?

I'm running Ubuntu 13.04.

2 Answers2

64

Fixed it by adding these lines to ~/.bash_profile on my local machine (OSX).

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
  • 2
    Actually, setting both LANG and LC_ALL makes little sense. And you should really take a look at /etc/default/locale to fix the issue system-wide. – Gunnar Hjalmarsson Jan 30 '14 at 12:17
  • 1
    @GunnarHjalmarsson On the server it's LANG=en_US.UTF-8. That file doesn't exist on OSX. – Markus Hedlund Jan 30 '14 at 13:23
  • 1
    Missed that you connect remotely. So apparently your local locale settings are exported to the server. In any case, given that LANG is used on the server, setting LANG in ~/.bash_profile ought to be sufficient. https://help.ubuntu.com/community/EnvironmentVariables#Locale_setting_variables describes the various locale categories. – Gunnar Hjalmarsson Jan 30 '14 at 16:40
  • I experienced the same problem (locale warning on tab for auto-complete) on remote sessions from OS X to Ubuntu. This answer worked for me as well. – Carl Oct 07 '16 at 21:51
  • This did not work for ubuntu machine. – alper Mar 02 '22 at 08:46
6

You may have some odd setting in /etc/default/locale. "UTF-8" is not a complete locale name.

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94