38

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.

Markus Hedlund
  • 1,253
  • 2
  • 12
  • 15
  • 1
    http://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue?rq=1 – kenn Jan 29 '14 at 10:11
  • 1
    UTF-8 as a locale-name looks wrong. – guntbert Jan 30 '14 at 21:35
  • 1
    Fixed on my ubuntu box by running: apt-get install language-pack-en-base, update-locale LC_ALL="en_GB.UTF-8", locale-gen (not GB not US) – PhoebeB Jun 05 '14 at 08:41
  • My answer is regarding Debian, but I was having this issue and simply ran `sudo dpkg-reconfigure locales` according to [Locale - Debian Wiki](https://wiki.debian.org/Locale) – waffl Jul 17 '14 at 10:42
  • This should be the duplicate of: [warning: setlocale: LC_ALL: cannot change locale](http://askubuntu.com/q/114759/78223) or [How to solve LOCALE problem](http://askubuntu.com/q/454260/78223). – kenorb Mar 25 '15 at 11:57
  • `dpkg-reconfigure locales` solved the problem for me :) – metakermit Sep 24 '15 at 09:08

2 Answers2

61

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
Markus Hedlund
  • 1,253
  • 2
  • 12
  • 15
  • 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
  • 32,938
  • 3
  • 63
  • 94